Hi,
I have some problems in PIC18f programming..
my task is to use PIC18f and SPI to read temperature data from CS5463. So I initialized the I/O ports of PIC18f and the SPI. but the temp. reading turned out to be very weird.. 70+ Celsius, while room temp. is about 20+only. the main program is as follows. I'm not sure if the command should be wirtten as "SSPBUF=00100110"? Plz help.
I have some problems in PIC18f programming..
my task is to use PIC18f and SPI to read temperature data from CS5463. So I initialized the I/O ports of PIC18f and the SPI. but the temp. reading turned out to be very weird.. 70+ Celsius, while room temp. is about 20+only. the main program is as follows. I'm not sure if the command should be wirtten as "SSPBUF=00100110"? Plz help.
//synchronize clock. connect the SCLK of CS5463 to RB1
LATBbits.LATB1 = 1;
//connect SDO RC7 to SDI of Cs5463
LATC = 0;
TRISC = 0;
PORTC = 0x00;
//initializing SPI operation
//SSPSTAT=11xxxxxx;
SSPSTATbits.SMP=1;
SSPSTATbits.CKE=1;
//SSPCON1=xx110000;
SSPCON1bits.SSPEN=1;
SSPCON1bits.CKP=1;
SSPCON1bits.SSPM3=0;
SSPCON1bits.SSPM2=0;
SSPCON1bits.SSPM1=0;
SSPCON1bits.SSPM0=0;
//control bits specified
//enabling I/O
//SDO must have TRISC<7> bit cleared
TRISCbits.TRISC7=0;
//SCK must have TRISB<1> bit cleared.
TRISBbits.TRISB1=0;
LATBbits.LATB1 = 1;
LATBbits.LATB0 = 1;
//send commands to read temp from CS5463
SSPBUF=00100110;
//delay so that the temp. value can be read
Delay10KTCYx(40);