Bonjour,
j'essaye de commencer la configuration d'une liaison I²C sur un µ ATmega16 cependant j'ai une erreur que je ne comprends pas.
Pourriez vous m'aider?
L'adresse que j'essaye d'envoyer est prise aléatoirement mais je ne penses pas que ce soit la le probleme.Code:#include <avr\io.h> #include <util\delay.h> #include <avr/iom16.h> #include <avr/interrupt.h> #include <avr/SBIT.h> #include <avr/delay_basic.h> #include <util/twi.h> #define F_CPU 16000000UL // 16 MHz unsigned char i2c_start(unsigned char slave_address){ // send START condition TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN); // Wait for TWINT Flag set. This indicates that the START condition has been transmitted while (!(TWCR & (1<<TWINT))); //Check value of TWI Status Register. Mask prescaler bits. If status different from START return 1 if ((TWSR & 0xF8) != TWSTA) return 1 // Load slave_address into TWDR Register. Clear TWINT bit in TWCR to start transmission of address TWDR = slave_address; TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN); //Wait for TWINT Flag set. This indicates that the SLA+W has been transmitted, and ACK/NACK has been received. while (!(TWCR & (1<<TWINT))); //Check value of TWI Status Register. Mask prescaler bits. If status different from TW_MT_SLA_ACK or TW_MR_SLA_ACK return 1 if ((TW_STATUS != TW_MT_SLA_ACK) && (TW_STATUS != TW_MR_SLA_ACK)) return 1; return 0; } int main (void){ unsigned char address = 0x02; i2c_start(address); return 0; }
Le message d'erreur est le suivant:
../I2C.c:21: error: called object '1' is not a function
Pourriez vous m'aider?
Merci par avance,
Cordialement,
Différent
-----