Hi folks!

I'm trying to communicate a PIC16F877 (VCC = 5V) and a SP12T (VCC = 5V) by SPI protocol and i juust doesn't works!

Can anybody help me? I've looked bilions of times to page 6 of the datasheet and i think that i'm doing it right!

My code is below: ( made in CCS compiler )

main () {

setup_spi(SPI_MASTER|SPI_L_TO_H|SPI_CLK_DIV_64);
(...)
output_high(NCS);

while(1) {

while(input(wakeUP) == 0) {


output_low(NCS); // envia o 3D
spi_write(0x31);
sok = spi_read(0); // Recebe 3D
output_high(NCS);
delay_ms(74);
printf("\n\r SOK0: %x",sok);

output_low(NCS);
sok = spi_read(0); // Recebe 3D
output_high(NCS);
printf("\n\r SOK1: %x",sok);

output_low(NCS);
output_high(NCS); // Zera a linha de comando
delay_ms(74);

output_low(NCS);
spi_write(0x31);
output_high(NCS);
delay_ms(74);


output_low(NCS);
sok = spi_read(0xFF);
output_high(NCS);
delay_ms(74);
printf("\n\r SOK2: %x",sok);
}
}


As u can see, I've tried in many diferent ways read the code 0x31 back!!!
I've also tried to get the ID codes of the sensor, but i got only crap!

Keyworks: SensoNor Infineon SP12T pressure TPMS sensor SPI microcontroler PIC CCS PicBasic