TLDR ATmega4809, mis-labelled ISR in iom4809.h. How can I define an ISR without using these mis-labelled predefined values from iom4809?
Using the ATmega4809 Xplained Pro eval board, I'm setting up asynchronous USART transmission, using the data register empty interrupt to always send the next available byte. If there are no more bytes to send, I disable the interrupt. I'm using the example USART project from MicroChip, directly from the Atmel Studio project generator.
/* Interrupt service routine for Data Register Empty */
ISR(USART1_DRE_vect)
{
// I need to handle this interrupt.
}
int8_t USART_0_init()
{
USART1.BAUD = (uint16_t)USART1_BAUD_RATE(9600); /* set baud rate register */
USART1.CTRLA = 0 << USART_ABEIE_bp /* Auto-baud Error Interrupt Enable: disabled */
| 0 << USART_DREIE_bp /* Data Register Empty Interrupt Enable: disabled */
| 0 << USART_LBME_bp /* Loop-back Mode Enable: disabled */
| USART_RS485_OFF_gc /* RS485 Mode disabled */
| 0 << USART_RXCIE_bp /* Receive Complete Interrupt Enable: enabled */
| 0 << USART_RXSIE_bp /* Receiver Start Frame Interrupt Enable: disabled */
| 0 << USART_TXCIE_bp; /* Transmit Complete Interrupt Enable: disabled */
USART1.CTRLB = 0 << USART_MPCM_bp /* Multi-processor Communication Mode: disabled */
| 0 << USART_ODME_bp /* Open Drain Mode Enable: disabled */
| 0 << USART_RXEN_bp /* Reciever enable: disabled */
| USART_RXMODE_NORMAL_gc /* Normal mode */
| 0 << USART_SFDEN_bp /* Start Frame Detection Enable: disabled */
| 1 << USART_TXEN_bp; /* Transmitter Enable: enabled */
USART1.CTRLC = USART_CMODE_ASYNCHRONOUS_gc /* Asynchronous Mode */
| USART_CHSIZE_8BIT_gc /* Character size: 8 bit */
| USART_PMODE_DISABLED_gc /* No Parity */
| USART_SBMODE_1BIT_gc; /* 1 stop bit */
}
No matter what I tried, I couldn't seem to get the data register empty interrupt to fire. I figured out that there was an inconsistency between the datasheet and the library that defines the interrupt vector.
From the 4809 datasheet:
26 0x1A 0x34 USART1 - Receive Complete
27 0x1B 0x36 USART1 - Data Register Empty
28 0x1C 0x38 USART1 - Transmit Complete
From iom4809.h
This doesn't match!! It is interrupt number 27 in data sheet and interrupt number 26 in the iom4809 library.
#define USART1_DRE_vect_num 26
#define USART1_DRE_vect _VECTOR(26)
#define USART1_RXC_vect_num 27
#define USART1_RXC_vect _VECTOR(27)
#define USART1_TXC_vect_num 28
#define USART1_TXC_vect _VECTOR(28)
How can I define an ISR without using these mis-labelled predefined values from iom4809?