Page 1 of 1

UART variable sized string receive with DMA and a timer

Posted: Wed Feb 25, 2015 10:10 pm
by rolanddixon
I am new to ChibiOS but have been developing on STM32 and LPC43xx MCUs in a super loop fashion for a while now. A functionality that I found useful was the ability to reset a general purpose timer counter (STM32) or the SCT (LPC43xx) from an external source without an interrupt (timer slave reset mode configuration on STM32). This allowed me to connect the UART receive source to the UART_RX pin and another pin that resets a timer count on any polarity transition. The DMA can then handle any UART receive by putting it onto a buffer and then if the timer counter ever reaches the value in the timer's Auto Reload Register (STM32) an interrupt is generated and we know that nothing is being sent anymore (transmission is finished) so we can then collect the data on the DMA buffer for processing. This allows variable sized string receives without any processor interaction at all as we can query the DMA counter in the interrupt routine once the receive is finished.

Is there any such functionality in the ChibiOS hal? I am currently using the Serial driver to receive each byte separately as it becomes available which is quite a resource intensive method (similar to https://github.com/grantmd/ChibiCopter/ ... ster/GPS.c).

This is useful for things like a GPS unit that sends NMEA strings of variable size.

Thank you for any help in advance.

Roland

Re: UART variable sized string receive with DMA and a timer

Posted: Wed Feb 25, 2015 10:26 pm
by Giovanni
Hi,

There is the UART driver which is unbuffered, fixed-size oriented and uses the DMA internally.

Giovanni

Re: UART variable sized string receive with DMA and a timer

Posted: Wed Feb 25, 2015 10:48 pm
by rolanddixon
Thank you for the quick reply.

So is there no way of reseting the a GPT based on an external signal transition without using an interrupt?

I have not looked into the hal underlying code much but could I program a timer (say TIM3 on the STM32F4xx) at register level to do slave resets without upsetting other Chibios peripheral drivers other than GTP?

I must say, I am impressed by chibiOS, how easy you have made it to get going, its functionalityand portability, so thank you.

Re: UART variable sized string receive with DMA and a timer

Posted: Thu Feb 26, 2015 2:56 pm
by Giovanni
Hi,

This may require some custom programming of timers, it is possible you could use the ICU driver for that (the overflow callback specifically).

Giovanni

Re: UART variable sized string receive with DMA and a timer

Posted: Sun Mar 01, 2015 10:19 pm
by rolanddixon
I did it by adapting the GPT drivers to reset on an external signal. Working like a charm. Thank you.

Re: UART variable sized string receive with DMA and a timer

Posted: Tue Mar 03, 2015 7:38 am
by chibby314
Have a look at the UART IDLE interrupt!
I use this Interrupt as an indication that the bus is idle .. (never guessed that - huh?)
In the ISR i check for transmitted / received byte count and signal tasks accordingly.

Best,
chibby