Hello. I've been messing a couple of months with microcontrollers. I have an arduino uno and try to make it communicate with a TC74A2 temperature sensor and get temperature sample. I don't want to use the arduino libraries ( i did it in the past with success ) in order to learn better the microcontroller internals. So i fetched the i2cmaster library. I use avrdude in my Debian terminal to upload the program and the i2cmaster library's make file to compile.
I write the code and it is not getting any values but this is not the problem is i'm just experimenting and probably the code isn't correct.
The problem:
I have an if-else statement to check if the communication has began and the TC74A2 address has been sent correctly. I have attached leds on PINB0 and PINB1. The code says that in either of the two cases the one led should turn on. But since i call the i2c functions in the statement no led turns on. On the other side in a simple if-else statement, without any i2c functions inside the one led turns on. For example:
if ( 1 ) { PORTB |= 1<<PINB0 } else { PORTB |= 1<<PINB1 }
Led turns on!
result = i2c_start(0x95); if ( result == '1' ) { i2c_stop(); PORTB |= 1<<PINB0; } else { PORTB |= 1<<PINB1; }
NO led turns on!
Say the code i'm writing about the i2c communication is totally wrong.. shouldn't at least one led turn on? That's my problem and i can't locate an answer. Do you have any idea?
Here is the i2cmaster library: http://homepage.hispeed.ch/peterfleury/i2cmaster.zip
I have attached the code and a screenshot from the TC40A2 sensor, specifically about the communication.