Registers Bit Fields

May 1st 2018

So I was writing a interrupt driven UART driver and found that my receiver interrupts were being turned off.  Thanks to the wonderful GNU MCU Eclipse plugin, https://gnu-mcu-eclipse.github.io/, I can view the registers of my processor and found:

If you look at the assembly code for:


SERCOM3->USART.INTENCLR.bit.TXC = 1; //turn off the transmit interrupts

This does a read an OR and a write, which for the interrupt clear it ends up clearing all the interrupts. 

Hence it is a good idea to only use the bit references for registers when doing a reads, not writes.