cinginanewlight
Joined: 29 Feb 2012 Posts: 1
|
PIC24F16KA102 SPI |
Posted: Wed Feb 29, 2012 6:33 am |
|
|
I'm new to PIC's and I am probably missing something very simple, but I can't get the h/w SPI to work.
The serial clock pin is pulled high and the data pin stays low.
My code is as follows, I've loaded it into two24F16KA102's, and I am using a scope to view the IC pins.
Code: |
#include <24F16KA102.h>
// compiler v4.120
#device ICD=TRUE
#fuses MCLR,NOWDT,NOPROTECT,NOBROWNOUT,HS
#use delay (clock=4M)
void main() {
/* while (true) {
output_toggle (PIN_B10); // check port h/w works- OK squarewaves can be seen
output_toggle (PIN_B11); // tried another chip too!
delay_ms(20);
} */
// setup_spi(SPI_MASTER | SPI_H_TO_L | SPI_XMIT_L_TO_H | SPI_CLK_DIV_16);
setup_spi(SPI_MASTER | SPI_H_TO_L | SPI_CLK_DIV_16);
while (true)
{
spi_write (0xFF); // RB10 sclk is pulled high
delay_ms(500); // RB11 sdata is 0V
spi_write (0x00);
delay_ms(500);
output_toggle(PIN_A4); //heartbeat LED OK!
}
} |
Any suggestions and help for a newbie will be gladly received. |
|