This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Keil CMSIS USART flow control and STM32

Hi,

I am using the STM32F437 USART with Keil PPP and a 2G/4G modem. Keil's PPP client uses Keil's CMSIS USART driver.

The STM32F437 USART has an automatic flow control feature. CTS and RTS will be handled automatically by the MCU. However, the MCU only has a 1 byte internal buffer which means that RTS is asserted/de-asserted on every received character.
This limitation means that if my MCU is communicating with the modem at a high baud rate of 2040800 then the RTS signal will be toggled at a rate of 230400 bits / (8 + 1 + 1) = 23040 bits per character = 1/23040 = 0.000043 secs = ~43uS. This means if the receiver is using interrupts it has to cope with them at a rate of 43uS. This gets worse if an even high baud rate is used. My GSM modem cannot cope with this fast IRQ rate.

Therefore I seem to have two options; reduce baud rate or implement manual flow control.
I would like to do the latter but this means delving into Keil's CMSIS USART driver code.
I have looked at the driver source code and the CMSIS interface but I am having difficultly in understanding how I can implement manual flow control.
Normally it would be a case of having a low/high watermark on a buffer and switch RTS high when the high watermark is reached an low when the low watermark is reached.
However, the CMSIS driver has no way of knowing how much data has been read from the buffer. The CMSIS interface requires the application to supply a pointer to the buffer and requests a number of bytes to be read via ARM_USART_Receive(). The application gets notified when the number of bytes have been read or it can poll for number of bytes read so far and abort the receive operation.
Therefore I could assert RTS when 2/3 of the bytes have been received but I won't know when to de-assert it.
Has anyone had any experience with this driver and implemented manual flow control?

Thanks