[SOLVED] TC72 interfacing with PIC18F452

Status
Not open for further replies.

syeda amna

Full Member level 4
Joined
Jun 1, 2010
Messages
222
Helped
24
Reputation
48
Reaction score
22
Trophy points
1,308
Location
Pakistan
basicelectronicsguide.blogspot.com
Activity points
2,551
I m trying to interface TC72 temperature sensor with PIC. I m using CCS compiler. The problem is SCK and SDO pins are in idle state.



Code:
#include <18F452.h>  
#fuses HS,NOWDT,NOPROTECT,NOLVP
#fuses XT             //for crystal
#use delay (clock=4000000)     
#include <flex_for_test_lcd.c>  //LCD driver

void main()
{ 

      int i;
      int value;
      output_low(PIN_E2);
      lcd_init();        
      

//SPI//


setup_spi(SPI_SLAVE | SPI_H_TO_L);

output_bit( PIN_C0, 1);   //Chip Enable
 printf(lcd_putc, "%u" i);

spi_write(0x02); //For normal mode
spi_write(0x80); //Control Register Addr

i=spi_read(0x02);  //Reading value from MSB
printf(lcd_putc, "%u" i);

}
 

I don't believe that the processor should be setup as a SPI slave. But it explains pretty well why you don't see any bus activity. I would try master mode.
 

I configured processor as a master.
Not in the code shown in post #1.
Code:
setup_spi(SPI_SLAVE | SPI_H_TO_L);
The setup is wrong in two regards: Setting slave mode and SPI mode 2. TC72 however expects mode 1 or 3. This setup should work:
Code:
setup_spi(SPI_MASTER);
 
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…