2021-12-14 07:24 AM
In a normal M4 like the STM32F466RE the MX program does most of the setup for transmitting the UART with DMA when you configure.
However there is NO DMA option when setting up the UART for the STM32MP157.
I dump internal information to a UART so I can see what is going wrong. The UART is operating at 2Mb (2,000,000 baud or bits per second) While that is good at getting the data out, it is too much of a drain on the processor going in and out of interrupts that fast.
That is what DMA is for. It operates in the background and is not noticed by my processor.
The DMA is different with the STM32MP1, some help with the configuring it with a UART for transmit would be helpful.
2021-12-14 07:44 AM
Hi @KiptonM ,
With STM32CubeMX, if UART is assigned to Cortex-M4, you could assign DMA2 streams to it and got most code ready to use.
I think your question is for Linux side.
As I'm not expert, I dig into ST MPU wiki and found the following information which could help setting tty with DMA:
https://wiki.st.com/stm32mpu/wiki/Serial_TTY_device_tree_configuration
Regards.
2021-12-14 10:04 AM
Actually my question is on the M4 side. Not the Linux A7 side.
So I went to DMA2 assigned it to M4
Then i added USART3_TX
The rest of the parameters I left to default.
HAL_UART_Transmit_DMA(&huart3, (uint8_t *)tcbuffer1, strlen((char *)str));
Does not work.
2021-12-16 01:13 AM
Hi,
Have you enabled "USART3 global interrupt' in CubeMX ?
See attached a quick and dirty example out of CubeMX with few lines added to start the TX.
Regards.
In order to give better visibility on the answered topics, please click on 'Select as Best' on the reply which solved your issue or answered your question. See also 'Best Answers'
2021-12-16 04:43 PM
The code looks almost identical except my does not output to the serial port.
The only difference I could see is that your version generated a Stream1 for RX I am guessing
static void MX_DMA_Init(void)
{
/* DMA controller clock enable */
__HAL_RCC_DMAMUX_CLK_ENABLE();
__HAL_RCC_DMA2_CLK_ENABLE();
/* DMA interrupt init */
/* DMA2_Stream0_IRQn interrupt configuration */
HAL_NVIC_SetPriority(DMA2_Stream0_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(DMA2_Stream0_IRQn);
/* DMA2_Stream1_IRQn interrupt configuration */
HAL_NVIC_SetPriority(DMA2_Stream1_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(DMA2_Stream1_IRQn);
}
and mine did not because I was not expecting anything coming in on USART3
/**
* Enable DMA controller clock
*/
static void MX_DMA_Init(void)
{
/* DMA controller clock enable */
__HAL_RCC_DMAMUX_CLK_ENABLE();
__HAL_RCC_DMA2_CLK_ENABLE();
/* DMA interrupt init */
/* DMA2_Stream0_IRQn interrupt configuration */
HAL_NVIC_SetPriority(DMA2_Stream0_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(DMA2_Stream0_IRQn);
}
Here is the screen shot with the Interrupt set.
2021-12-16 04:45 PM
2021-12-17 12:11 AM
Hi @KiptonM,
how did you test your M4 code ? using Engineering mode or Production mode ?
In Production mode, as peripheral root clock init is done by Linux, your Device Tree matters.
I tested (In engineering mode with latest CubeIDE) and still work when removed DMA stream1 on RX.
Regards.
2021-12-17 12:15 AM
Btw, did you check you defined the right USART3 pins in CubeMx ?
Per default, even if starting from a DK2 project, CubeMx will not automatically use the USART3 pins defined in the DK2 board schematics (which should be USART3_TX on PB10, USART3_RX on PB12).
Regards.