//************************************************************ // ******** FUNCTIONS FOR I2C COMMUNICATION ******* //************************************************************ //Controller : ATmega32 (Clock: 8 Mhz-internal) //Compiler : AVR-GCC (winAVR with AVRStudio-4) //Project Version : DL_1.0 //Author : CC Dharmani, Chennai (India) // www.dharmanitech.com //Date : 10 May 2011 //************************************************************ #include #include "i2c_routines.h" #include "UART_routines.h" //************************************************ //TWI initialize // bit rate:18 (freq: 100Khz @16MHz) //************************************************ void twi_init(void) { TWCR= 0x00; //disable twi TWBR= 0x12; //set bit rate TWSR= 0x00; //set prescale //TWCR= 0x44; //enable twi } //************************************************* //Function to start i2c communication //************************************************* unsigned char i2c_start(void) { TWCR = (1<