PDA

View Full Version : Help with SPI SP12T!!!!!!



rush-bh
- 4th April 2005, 21:44
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

NavMicroSystems
- 4th April 2005, 22:54
rush-bh

This is a PICBASIC Forum, not a CCS Forum !

rush-bh
- 5th April 2005, 13:50
Ralph,

I know it is an PICBASIC forum... I don't care wich compiler use, i just want do communicate a PIC and a IC! In my opinion, foruns about Microcontrolers are just about it, make things works! The compiler is just a language to make it work!

NavMicroSystems
- 5th April 2005, 17:12
rush-bh

This is a PICBASIC Forum, not a MicroController Forum.

If you don't care about a compiler, why don't you use PICBASIC?

Please see also: This (http://www.picbasic.co.uk/forum/showthread.php?t=1254)

rush-bh
- 6th April 2005, 20:47
Worked fine RALPH, thanks 4 your help! hehehehe

I used transistors to switch the 3.3v ( new voltage of SP12T ) and the 5V ( PIC ). The transistors were to slow for 312,5MHz! The CLOCK lost the syncronism with SDO and SDI!

A tip for the guys who have problems with 3.3v <-> 5v :
MAXIM MAX3392E

Good luck for you guys, and sorry for the PIC and CCS problems in a PICBASIC forum.

NavMicroSystems
- 6th April 2005, 22:44
Worked fine RALPH, thanks 4 your help! ...

You're welcome