Atmega4809 Asynchronous USART doesn't trigger data register empty interrupt - iom4809.h error
Update: There is a device pack in Atmel Studio to fix the iom4809.h library.


  Please update ATmega DFP from the pack manager available from Studio:
  Tools -> Device Pack Manager.
  
  In case if you get any time out error while installing the packs from
  Studio: Tools -> Device Pack Manager, device packs can be directly
  downloaded from http://packs.download.atmel.com/
  
  Once the required pack is downloaded, double click the atpack file to
  open and install the same.




The only thing those macros do is define a vector location from a number through _VECTOR().

You can do it "quick-hack" style, by just inserting _VECTOR(27) in your ISR and label it as /* This is a hotfix, as the DRE vector is mis-labled in the ASF library, 27 is DRE. */.

That would be considered "Magic Number Coding", which is essentially a bad practise, but for a quick test it's an option.

But, you can also make it more intelligent and clean, you can undefine a constant using #undef.

You can also check values with #if.

To start simple, you could write:

#if (USART1_DRE_vect_num == 26)
  #undef USART1_DRE_vect
  #undef USART1_DRE_vect_num
  #define USART1_DRE_vect_num    27
  #define USART1_DRE_vect        _VECTOR(27)
#endif


And you can even, to make it cleaner add a device-type check around it, there's a lot of examples of that in the libraries themselves. I think Atmel Studio uses the "DEVICE" or "TARGET" identifier for that by default, but I'm not at my dev lab, so can't check right now.

Then you can just make a whole "Clean-Up" header for all the mistakes that checks if they still exist in the library. Maybe you can also add a line like:

#warning "Overrode a default Atmel identifier as they do not conform to the datasheet"


Then if after an update the warnings disappear, you know you can disable your header.

Make sure you include an over-ride header last, else your definition may not be triggered, since an undefined variable doesn't trigger the "== 26".

In fact, technically you should add defined(USART1_DRE_vect_num) to your #if clause to check for that yourself, to make your code universally compatible. But then, you probably want to check more extensively and add more warnings or errors, because in that case something will go wrong down the line anyway.

If you do NOT care at all about your project's portability to any other computers, you could also edit the header file itself, but I'd strongly suggest you try to avoid that as a matter of standard practise.



Last note: I have a gut feeling someone at some point in the future is going to say something incomprehensibly stupid like "Just use the vector with the right number". Which creates badly documented code at the very least and is dangerous. Your code will read as if you are doing something very silly on a completely different named interrupt. (And will stop working when they fix the bug)

Oh, and, file a bug report!

To summarize the "workaround" until MicroChip fixes the library:

#if (defined(USART1_DRE_vect_num) &amp;&amp; USART1_DRE_vect_num == 26)
    #warning "Overrode a default Atmel identifier as they do not conform to the datasheet"
    #undef USART1_DRE_vect
    #undef USART1_DRE_vect_num
    #undef USART1_RXC_vect
    #undef USART1_RXC_vect_num
    // Redefine to vector numbers to match the ATmega4809 datasheet
    #define USART1_DRE_vect_num    27
    #define USART1_DRE_vect        _VECTOR(27)
    #define USART1_RXC_vect_num    26
    #define USART1_RXC_vect        _VECTOR(26)
#endif