STM32 9 bit UART and DMA adventures
Posted: 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
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