STM32 9 bit UART and DMA adventures

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderators: RoccoMarco, barthess

law
Posts: 4
Joined: Tue Jan 12, 2016 5:20 am
Been thanked: 1 time

STM32 9 bit UART and DMA adventures

Postby law » Fri Sep 15, 2017 5:19 am

Hiya,

This is not strictly a ChibiOS related question, although I am using ChibiOS.

I'm working on a project where at some point in the operation of my device, I want to change the UART operating mode from 8 bit (N81) to 9 bit and use the MSB as an address flag. This is supported as multiprocessor mode on the STM32F7's I'm using.
The main issue with this is that I want to point the DMA peripheral to byte wide buffers in both modes. In 9 bit mode I don't really care about the 9th MSB, I just want to use it as a signal to enable/disable mute mode.
I can get this work fine if I do the following:
On the receiver:
- set up 9 bit mode with normal mute mode settings in CR1 and CR2.
- Modify uart_lld to remove the line :
uartp->dmamode |= STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD;
so that I receive to an 8 bit buffer
- Set up a byte wide buffer to receive into
- Start receiving etc

On the sender If I setup 9 bit mode and manually send by doing:
- UARTD6.usart->TDR = val_8[0];
- (where val_8 is uint8_t)
this will work just fine.

However, on the sender side if I use DMA transfers, and try to transfer byte wide values, things do not work the way I want and I get data that almost correct in that values are just repeated etc.

I'm aware this idea might be fundamentally flawed, but can anyone offer any advice?

Thanks very much

law
Posts: 4
Joined: Tue Jan 12, 2016 5:20 am
Been thanked: 1 time

Re: STM32 9 bit UART and DMA adventures

Postby law » Thu Sep 28, 2017 1:46 am

Hiya,

I thought I might post a reply to this.
I also asked this question on the ST forums and the general consensus is that it will not work.
With the UART in 9 bit mode and the DMA writing bytes (uint8), the APB bridge will duplicate bytes (or uint16s) to fill the 32 bit register.
This resulted in the 9th bit of the UART (Address indicator bit) reflecting what was being placed in bit 0 by the DMA.
This is a shame.. As a work around I'm using busy waiting to send data, but using DMA to receive.

Here is the ST forum post link:
https://community.st.com/message/168894 ... rt-and-dma

Thanks!

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: STM32 9 bit UART and DMA adventures

Postby Giovanni » Thu Sep 28, 2017 6:41 am

Thanks for the info, I really didn't have any answer for this.

You may try to write half works but that would require your buffers to be organized that way.

Giovanni


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 33 guests