cancel
Showing results for 
Search instead for 
Did you mean: 

STM32Cube UART variable length receive

Roth.Ian
Associate II
Posted on October 28, 2014 at 20:10

Is it possible to receive variable length messages in DMA mode with the STM32Cube HAL libraries? It seems like this should be possible at the hardware level by first looking for the RXNE interrupt, and then the Idle interrupt.

4 REPLIES 4
Osto
Senior
Posted on October 30, 2014 at 18:26

Hi,

The Cube and HAL dont Support variable length data Input with Serial Interface (polling, Interrupt and DMA). You have to code it yourself. The only way is to use polling Methode with timeout.

I  had the same Problem and have to write my own Service routine. The easiest way is to copy the HAL routines to your own c-Files and Change the Name to prefix my.... then Change in the Interrupt table all needed UARTs to Point to your ''my'' Service Routine and do it as you need. This is the fastest way.

Please take care that everytime you generate the Project with Cube, you have to Change again the Interrupt table to Point to your ''my'' functiuons else it will Point back to HAL functions.

rchris
Associate II
Posted on November 17, 2014 at 13:35

Hi,

I had USART RX with variable length running using DMA and the Idle interrupt with the old Standard Peripheral Library. Now I wanted to move to the latest version of CMSIS which seems to support idle detection on an ''optional'' basis (ARM_USART_EVENT_RX_TIMEOUT). Unfortunately, the Cube driver does not support this.

Can anyone from ST comment on why this was not realized although the hardware supports it and if this will be available in an update?

Posted on January 12, 2015 at 16:42

Hi,

I don't really have enough insight into what specifically you are doing. I'm not sure I fully understand your thread: USART RX with variable length running using DMA and the Idle.

Could you provide a little more information about the issue you’re experiencing?

Regards,

Heisenberg.

rchris
Associate II
Posted on January 13, 2015 at 10:48

Hi,

at the time I was assuming that the CMSIS USART driver supplied by Keil (I use  MDK) would use the Cube HAL driver. This is not so. Nevertheless, many systems use USART communication where the receiving system does not know, how long a message will be, please see [DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Java/Need%20help%20with%20RS232%20receive%20%20STMCubeMx&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000F9A0E3A95BA69146A17C2E80209ADC21&currentviews=321]this thread. If you look around, you will find even more requests who need this. The Idle interrupt is a feature of STM32F2XX and probably also others. This worked for me using the old SPL.

CMSIS driver also does not suppport this. Keil support has entered a feature request for this for the CMSIS development team. HAL drivers should support this, too.

I needed to do this with interrupts, so I ended up using the CMSIS driver receiving only one character at a time and checking contents. I refrained from using  DMA, because at the time I had found a bug in the CMSIS USART driver making RX DMA not working, about which I informed Keil. This was corrected in the next release.