hello,
j'ais le meme problème, je travail avec une Arduino Mega (Atmega1280); j'ais configuré l'USART comme suit:
void USART1_Config(){
sbi(UCSR1A, TXC1); // set transfer complete flag (TXC1 = 1).
cbi(UCSR1A, FE1); //clear Frame Error flag (FE1 = 0).
cbi(UCSR1A, DOR1); //clear Data overrun flag (DOR1 = 0).
cbi(UCSR1A, UPE1); //clear Parity overrun flag (UPE1 = 0).
cbi(UCSR1A, U2X1); //disable doubling of USART transmission speed (U2X1 = 0).
cbi(UCSR1A, MPCM1); //Disable Multi-Processor Communication Mode-- whatever that is. (MCPM1 = 0)
cbi(UCSR1C, UMSEL10); //USART Mode select -- UMSEL10 = 0 and UMSEL11 = 0 for asynchronous mode.
cbi(UCSR1C, UMSEL11); //disable parity mode -- UPM10 = 0 and UPM11 = 0.
cbi(UCSR1C, UPM10);
cbi(UCSR1C, UPM11);
sbi(UCSR1C, USBS1); //Set USBS = 1 to configure to 2 stop bits per DMX standard.
sbi(UCSR1C, UCSZ10);//configuring for 8 data bits by setting UCSZ10 and UCSZ11 to 1.
sbi(UCSR1C, UCSZ11);
cbi(UCSR1C, UCPOL1);//Set clock parity to 0 for asynchronous mode (UCPOL1 = 0).
UBRR1L = baudprescale; // Load lower 8-bits of the baud rate value into the low byte of the UBRR register
UBRR1H = (baudprescale >> 8); // Load upper 8-bits of the baud rate value into the high byte of the UBRR register
sbi(UCSR1B,RXEN1);
sbi(UCSR1B,TXEN1);
}
puis j'ais fait l'appel à l'interruption ISR(USART1_RX_vect)
void setup(){
baudprescale = (((clockspeed / (baud * 16UL))) - 1);
cli(); //disable interrupts while initializing the USART
USART1_Config();
USART2_Config();
sei(); // Enable the Global Interrupt Enable flag so that interrupts can be processed
sbi(UCSR1B,RXCIE1);
}//end setup()
ISR(USART1_RX_vect){
Serial.print(UDR1);
}
j'ais essayé d'affiché le contenu du registre UDR1 et ça ne marche pas; cependant si je le met dans le void loop() il affiche normalement
je pense que c'est un problème de syntax de l'appel d'interruption...