abilashjoseph
Member level 1
hi,
I am using atmega8 to interface i2c(TWI), i am a beginner in I2C. from my knowledge I wrote a code,
that is given below. but i don't get any response or status,
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/twi.h>
void twi_init(void)
{
TWBR = 32;
TWCR = (1<<TWEN);
}
void twi_start(void)
{
TWCR = (TWCR & 0x0f) | (1<<TWINT)|(1<<TWSTA);
}
int main(void)
{
DDRC = 0xff;
twi_init();
twi_start();
}
is this code is correct?, any other codes are needed?
please help.
thanks .
I am using atmega8 to interface i2c(TWI), i am a beginner in I2C. from my knowledge I wrote a code,
that is given below. but i don't get any response or status,
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/twi.h>
void twi_init(void)
{
TWBR = 32;
TWCR = (1<<TWEN);
}
void twi_start(void)
{
TWCR = (TWCR & 0x0f) | (1<<TWINT)|(1<<TWSTA);
}
int main(void)
{
DDRC = 0xff;
twi_init();
twi_start();
}
is this code is correct?, any other codes are needed?
please help.
thanks .