takao21203
- Joined Apr 28, 2012
- 3,702
have done that 2012, interfacing a 1.8" with 18F PIC + using hardware SPI.
PIC32 is a better match for that.
PIC32 is a better match for that.
Craig,Just had a few hours trying to get hardware SPI working on a PIC18LF26K22. If anyone is interested, here is how you write to the SPI bus:
The while (!BF) doesn't seem to work on the 18F PIC I'm using, so here I clear the 'transmit finished' interrupt flag, load the buffer, then wait for the flag to set before continuing. Then clear it again.Rich (BB code):SCE = 0; // Chip enable PIR1bits.SSP1IF = 0; // clear the SSP transmit finished interrupt flag SSP1CON1bits.WCOL = 0; // clear write collision bit SSP1 SSP1BUF = data; // Load data into buffer SSP1 while(!PIR1bits.SSP1IF); // wait for SSP interrupt flag to say transmit is finished SCE = 1; // Chip enable
by Jake Hertz
by Aaron Carman
by Jake Hertz