Hi all again! I have a new problem today, and it's with the I2C bus. Specifically, what the behavior is when the device you are addressing is off.
So, as background, I am writing code to control a system with a controller board and daughter cards. There can be up to 10 daughter cards installed, but by the system's design there can be any number from 1 to 10 actually inserted at any time. I am using a Mega for the controller board and a Mega for each card, and am using I2C to communicate with them. I can talk to all of them just fine IF they are installed, but the problem comes when I try to determine whether or not the cards are there.
I am using Atmel Studio and C, but I took the Arduino Wire interface's underlying C library to use, "twi.h - TWI/I2C library for Wiring & Arduino" and twi.c from the arduino library if you want to follow along. I used the twi_writeTo() function, which should return 0 for success, 1 for length too long for buffer, 2 for address NACK, 3 for Data NACK and 4 for other bus error. When sending to a card that is plugged in, it returns 0 and I can see the result in the status LEDs that it worked. When I try to send a command to a removed card, I either get a 0 returned immediately (which is bizarre because how did a removed device ACK?) or it hangs forever, as if I didnt have pull-up resistors on the line (I do, and don't get ACK problems with micros I can see, which should be the case if I had SCL problems).
I am at my wit's end with this particular issue, and it's holding up my project because this behaviour is critical to the functionality of the system. Any help will, as usual, be greatly appreciated.