UartEvent icon indicating copy to clipboard operation
UartEvent copied to clipboard

RX interrupt (serial_dma_rx_isr) sometimes not fired

Open jymoulin opened this issue 9 years ago • 7 comments

Hi, I'm using a teensy3.2 and UartEvent on TX2/RX2 with alternate port (pin 26 and pin 31 instead of pin 9 and pin 10). I updated Uart2Event to use CORE_PIN26_CONFIG and CORE_PIN31_CONFIG in serial_dma_begin() and serial_dma_end().

A UART GPS is connected to this two pin (26 and 31). The code using UartEvent is very simple:

Uart2Event GPS; GPS.txEventHandler = GPSTx; GPS.rxEventHandler = GPSRx; GPS.rxTermCharacterTrigger = '\n'; GPS.begin(38400);

GPSTx does nothing and GPSRx just copies available bytes into a buffer.

After a cold reboot, everything works fine.

Sometimes, after a soft reset (to upload new code), the GPS is sending data as usual but the serial_dma_rx_isr() doesn't start. As if it doesn't receive data on the RX pin.

What could go wrong (uart clock sync?) ? And how to 'reset' the DMA handler ?

Thank you !

Best, jym

jymoulin avatar Jul 07 '16 10:07 jymoulin

I never used alt pins so I will have to investigate this, can you try the loopback example with the alt pins? Just make sure nothing is plugged into those pins when trying that example.

duff2013 avatar Jul 07 '16 14:07 duff2013

That's strange: the loopback example doesn't work, even without my modification for alternate pin. I tried Uart1, Uart2 and Uart3.

In fact, only one example is working: Fill_internal_buffer_time. The others: loopback, bufferSize, ReadBytesUntil doesn't.

The loopback example freezes because buffer is full (Event.availableForWrite() returns 0). The rxEvent() is never started.

I tried on a teensy3.2 (some devices connected and RTC crystal soldered but nothing on serial pin), and a teensy3.1 (nothing connected but RTC crystal soldered). My last board, without RTC, is a Teensy3.0, which cannot use UartEvent.

I'm using teensyduino version 1.27, arduino version 1.6.7.

jymoulin avatar Jul 07 '16 15:07 jymoulin

I have the loop back working here for over an hour with no problems yet. Are you sure you didn't edit something else in the library? I'm using the current version on github and using latest Teensyduino and Arduino IDE. Probably should get you working with the examples before tackling your particular problem with the GPS unit.

duff2013 avatar Jul 07 '16 19:07 duff2013

I agree :-) So, I ran tests with a fresh install of Arduino-1.6.8, Teensyduino-1.28 and new clone of UartEvent.

The loopback example works only with teensy clock of 96Mhz (optimized or not). All other clock speed doesn't work.

Which clock are you using ?

jymoulin avatar Jul 08 '16 10:07 jymoulin

That example is using 6MHz baud, try changing it something more reasonable like 115200 baud.

duff2013 avatar Jul 08 '16 15:07 duff2013

Ok, every clock speed works fine with 115200 baud. Even when using alternate pin (26 and 31) for TX2.

jymoulin avatar Jul 08 '16 15:07 jymoulin

Good, at least this example works now. I should probably change that example baud rate to something all cpu speed can do:)

duff2013 avatar Jul 08 '16 15:07 duff2013