Arduino Due Serial Interrupt
Well, I have got to the bottom of this problem. Not sure it's the best answer but it's a solution. The long and short of it is to avoid TXBE interrupts.
If I use TXEMPTY interrupts instead it works fine. A line on page 168 of the Atmel data sheet says (sic) 'A interrupt can enter pending state even it is disabled' so I wondered if the problem with TXBE was because I was not clearing the pending interrupt before or even inside the ISR so I added NVIC_ClearPendingIRQ(UART_IRQn); at the start of the ISR and also just before I enabled the TXBE interrupt but the (mis)behaviour didn't change. The operation of TXEMPTY is still a little odd (to me) because it appears that the interrupt is generated by the transmit shift register just being empty, not when it goes empty.
If you enable interrupts without having loaded the transmit buffer you will immediately get an interrupt. Some may like this 'self=priming' behaviour, but it doesn't do it for me. I am writing my sending routine such that the TXEMPTY interrupt is not enabled until the transmitter has been loaded with the first byte to be sent.
Arduino Interrupts - Learn Arduino in simple. Interrupts, Communication, Inter Integrated Circuit, Serial. (pin, ISR, mode); //recommended Arduino Due. Arduino DUE, Serial interrupt procedure to wakeup from sleep mode. Arduino does not return from serial interrupt routine correctly. I would like to use multiple. I'm simply trying to get my Arduino DUE to toggle a pin based on. My Arduino DUE not recognize my external interrupt? Until it receives data over serial?
Based on this post on the Arduino Forum: I presume that the USARTs have a similar issue. Patch Management With Kaseya. Hopefully this will help others.
I just realised what could be the real error at the source of my problem. The UART interrupt register descriptions talk about the TXBUFE bit in the context of transmit buffer empty and so my assumption was that this is the bit that tells me when I can put another byte into the transmit holding register.
However the UART Status Register description say that the TXBUFE bit is 'the buffer full signal from the transmitter PDC channel'. The latter puts a whole different slant on what this bit does. According to the UART Status Register description the bit I need to be looking at is the TXRDY bit!
See Also • () • - Demonstrates Arduino's advanced serial output functions. • - Move the mouse to change the brightness of an LED. • - Send data to the computer and graph it in Processing. • - Send MIDI note messages serially. • - Use two of the serial ports available on the Arduino and Genuino Mega. • - Turn a LED on and off by sending data to your board from Processing or Max/MSP.
• - Parse a comma-separated string of integers to fade an LED. • - Send multiple variables using a call-and-response (handshaking) method. • - Send multiple variables using a call-and-response (handshaking) method, and ASCII-encode the values before sending.