PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Dec 17, 2009 1:46 pm |
|
|
Your program is too complicated. Make a simple program that will
just put out SPI clock and data. Example:
Code: |
#include <18F4620.h>
#fuses HS,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay(clock=20000000)
#define SPI_MODE_0 (SPI_L_TO_H | SPI_XMIT_L_TO_H)
#define SPI_MODE_1 (SPI_L_TO_H)
#define SPI_MODE_2 (SPI_H_TO_L)
#define SPI_MODE_3 (SPI_H_TO_L | SPI_XMIT_L_TO_H)
//===============================
main(void)
{
setup_spi(SPI_MASTER | SPI_MODE_0 | SPI_CLK_DIV_16);
while(1)
{
spi_write(0x55);
delay_us(100);
}
} |
Quote: | #INT_SSP
void ssp_handler()
{
disable_interrupts(GLOBAL); // Not necessary
printf("\r\n Interrupt on SPI");
enable_interrupts(GLOBAL); // Very bad
} |
Don't ever do this. You have never seen us do this on the forum.
Read the forum and the PIC data sheet. Don't enable global interrupts
inside an interrupt service routine. |
|