atmega128l,i2c问题TWCR = (1 < <TWINT)|(1 < <TWSTA)|(1 < <TWEN);
while (!(TWCR & (1 < <TWINT)));
if ((TWSR & 0xF8) != 0x08) error();
总在执行error();
void port_init(void)
{
PORTA = 0xFF;
DDRA = 0x00;
PORTB = 0xFF;
DDRB = 0x00;
PORTC = 0xFF;
DDRC = 0x00;
PORTD = 0xFF;
DDRD = 0x00;
PORTE = 0xFF;
DDRE = 0x00;
PORTF = 0x0F;
DDRF = 0xF0;
PORTG = 0x1F;
DDRG = 0x00;
}
void twi_init(void)
{
TWCR= 0X00; //disable twi
TWBR= 0x32; //set bit rate
TWSR= 0x00; //set prescale
TWAR= 0x02; //set slave address
}
pd0,pd1,是scl,sda
我现在,在做这项工作,急,谢了