Hi,
I am using using Peter Fluery's i2c library for my ATMEGA2560. I am trying to do simple scan of the bus. I only have 1 device on the bus at address 0xC8, however the library says there is another device at 0xC9. When I connect an analyzer up I see it reads the the following write command as a read.
Here is my code:
#include <asf.h> #include "uart_config.h" #include <util/delay.h> #include <avr/power.h> #include "i2cmaster.h" int main (void) { unsigned char ret; uint8_t ack = 0; board_init(); usart_init(); printf("ATMEGA2560 i2c Scanner Rev 2\n\r"); i2c_init(); // initialize I2C library uint8_t address = 0; for( address = 0; address < 255;address++){ ret = i2c_start(address+I2C_WRITE); // set device address and write mode if ( ret ) { i2c_stop(); } else { printf("Found Device on 0x%02X\n\r", address); i2c_stop(); } } while(true){ } }
I would expect the i2c_stop() to release the bus and start all over. Any help is appreciated.