Gast
#1879589
Hallo allerseits,
ich glaube ich bin blind.
Kann mal jemand das Code Schnipsel ansehen und mir sagen warum nicht das
rauskommt was ich erwarte.
uint8_t TWIM_Write (uint8_t byte) {
uint8_t i8_twst;
// Send data to the previous addressed device
TWDR = byte;
TWCR = (1<<TWINT)|(1<<TWEN);
// Wait until transmission completed
while (!(TWCR & (1<<TWINT)));
// Check value of TWI Status Register. Mask prescaler bits
i8_twst = (TWSR & 0xF8);
if (i8_twst != 0x28 /*TWI_MTX_DATA_ACK*/) {
printf("TWIM_Write expected %0X\n", 0x28/*TWI_MTX_DATA_ACK*/);
printf("TWIM_Write status returned was %0X\n", i8_twst);
printf("returning 1\n");
return 1;
} else {
printf("TWIM_Write expected %0X\n", 0x28/*TWI_MTX_DATA_ACK*/);
printf("TWIM_Write status returned was %0X\n", i8_twst);
printf("returning 0\n");
return 0;
}
}
printf ist auf den UART umgelenkt und angezeigt wird :
TWIM_Write expected 28
TWIM_Write status returned was 28
returning 0
Compiler ist
avr-gcc (GCC) 4.3.4
auf einem UBUNTU 10.04
Controller ist ein m32
Danke schon mal
Ju