TCN75 I2C(TWI) and Atmega48

Post your requests and ideas on the future development of mikroC PRO for AVR.
Post Reply
Author
Message
ackoo88
Posts: 2
Joined: 04 Mar 2013 22:47

TCN75 I2C(TWI) and Atmega48

#1 Post by ackoo88 » 05 Mar 2013 18:11

hi,
I want to read temp with TWI from sensor TCN75. Here is my simple code.


char uart_rd,h=0,l=0;

void main(){

UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(100); // Wait for UART module to stabilize
UART1_Write_Text("Init");
TWI_Init(100000);

while(1)
{ TWI_Start();
TWI_Write(0x90);
TWI_Write(0x01);
TWI_Start();
TWI_Write(0x91);
h=TWI_Read(0u);
l=TWI_Read(1u);
UART_Write(h);
UART_Write(13);
UART_Write(l);
Delay_ms(2000);
TWI_Stop();

} }

But this code is not working, just wrint ,,Init" and after that nothing happens.When i reset again write ,,Init" and nothig happens.I dont know why. Can you help me?
Is somebody work with this sensor?

Post Reply

Return to “mikroC PRO for AVR Wish List”