Hi,
My USART interrupt continuously trips on the RXCIF flag even though there is no data line connected. I am reading both RXDATAL and RXDATAH in the interrupt to reset the flag each time (confirmed that the flag is reset), but it just trips again.
Interrupt:
// Interrupt vector for USART RX ISR(USART0_RXC_vect) { // Store character received uint8_t tempCharH = USART0.RXDATAH; uint8_t tempChar = USART0.RXDATAL; // Counting int uint8_t i = 0; // If char is start of a command... if(tempChar == '$') { // Reset position to zero in buffer strPosition = ctrlString; // Clear buffer for (i = 0; i < CTRL_LEN; i++ ) { ctrlString[i] = 0; } } // If char is end of a command '!'... if(tempChar == '!') { // Set command flag isCommand = TRUE; } // Write character to buffer *strPosition = tempChar; // Shift position strPosition++; }
Initialization:
// Initialize USART comms void USART_Init() { // Set RX pin to input PORTA.DIRCLR = PIN2_bm; // Set BAUD rate USART0.BAUD = BAUD_REGISTER; // Set receive complete flag USART0.CTRLA = USART_RXCIE_bm; // Turn on RX hardware USART0.CTRLB = USART_RXEN_bm; }
Thank you,
Tom