I2C

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

I2C

#1 Post by ackoo88 » 06 Mar 2013 18:09

I also try with Soft_I2C, but i always get FF value. Here is my code.

char uart_rd,h=0,l=0;

sbit Soft_I2C_Scl_Output at PORTC0_bit;
sbit Soft_I2C_Sda_Output at PORTC1_bit;
sbit Soft_I2C_Scl_Input at PINC0_bit;
sbit Soft_I2C_Sda_Input at PINC1_bit;
sbit Soft_I2C_Scl_Direction at DDC0_bit;
sbit Soft_I2C_Sda_Direction at DDC1_bit;

void main(){

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

while(1)
{
Soft_I2C_Start();
Soft_I2C_Write(0x90); // A2,A1,A0 on GND adrress 0x48 + W
Soft_I2C_Write(0x00); // set temp register
Soft_I2C_Start();
Soft_I2C_Write(0x91); // A2,A1,A0 on GND adrress 0x48 R
h=Soft_I2C_Read(0);
l=Soft_I2C_Read(1);

UART_Write(h); //send first byte
UART_Write(13); // send second byte
UART_Write(l);
Delay_ms(2000);


} }

I cant see what is problem. Does anyone else have the same problem?

Post Reply

Return to “mikroC PRO for AVR Wish List”