2024-11-27 05:13 AM
Used STM32CubeIDE version: 1.15.1
Used driver library: STM32Cube_FW_G0_V1.6.2, LowLevel-Drivers
Microcontroller STM32G0B0xx
LL Drivers have been selected for DMA and all other peripherals as far as possible.
There are several bugs in the generated code.
Bug #1
Even though LL drivers should be used, MX_DMA_Init() looks like this:
/**
* Enable DMA controller clock
*/
void MX_DMA_Init(void)
{
/* Init with LL driver */
/* DMA controller clock enable */
LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_DMA1);
__HAL_RCC_DMA2_CLK_ENABLE(); // <- Should be LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_DMA2) instead!
/* DMA interrupt init */
/* DMA1_Channel1_IRQn interrupt configuration */
NVIC_SetPriority(DMA1_Channel1_IRQn, 1);
NVIC_EnableIRQ(DMA1_Channel1_IRQn);
/* DMA1_Channel2_3_IRQn interrupt configuration */
NVIC_SetPriority(DMA1_Channel2_3_IRQn, 1);
NVIC_EnableIRQ(DMA1_Channel2_3_IRQn);
/* DMA1_Ch4_7_DMA2_Ch1_5_DMAMUX1_OVR_IRQn interrupt configuration */
NVIC_SetPriority(DMA1_Ch4_7_DMA2_Ch1_5_DMAMUX1_OVR_IRQn, 1);
NVIC_EnableIRQ(DMA1_Ch4_7_DMA2_Ch1_5_DMAMUX1_OVR_IRQn);
}
Bug #2
I use DMA for USART. The DMA initialization code generated in MX_USART6_UART_Init() is invalid:
void MX_USART6_UART_Init(void)
{
// ...
/* USART6 DMA Init */
/* USART6_RX Init */
LL_DMA_SetPeriphRequest(DMA2_Channel3, DMA2_Channel3, LL_DMAMUX_REQ_USART6_RX); // Should look like this: LL_DMA_SetPeriphRequest(DMA2, LL_DMA_CHANNEL_3, LL_DMAMUX_REQ_USART6_RX), following lines are invalid, too
LL_DMA_SetDataTransferDirection(DMA2_Channel3, DMA2_Channel3, LL_DMA_DIRECTION_PERIPH_TO_MEMORY);
LL_DMA_SetChannelPriorityLevel(DMA2_Channel3, DMA2_Channel3, LL_DMA_PRIORITY_HIGH);
LL_DMA_SetMode(DMA2_Channel3, DMA2_Channel3, LL_DMA_MODE_NORMAL);
LL_DMA_SetPeriphIncMode(DMA2_Channel3, DMA2_Channel3, LL_DMA_PERIPH_NOINCREMENT);
LL_DMA_SetMemoryIncMode(DMA2_Channel3, DMA2_Channel3, LL_DMA_MEMORY_INCREMENT);
LL_DMA_SetPeriphSize(DMA2_Channel3, DMA2_Channel3, LL_DMA_PDATAALIGN_BYTE);
LL_DMA_SetMemorySize(DMA2_Channel3, DMA2_Channel3, LL_DMA_MDATAALIGN_BYTE);
/* USART6_TX Init */
LL_DMA_SetPeriphRequest(DMA2_Channel4, DMA2_Channel4, LL_DMAMUX_REQ_USART6_TX);
LL_DMA_SetDataTransferDirection(DMA2_Channel4, DMA2_Channel4, LL_DMA_DIRECTION_MEMORY_TO_PERIPH);
LL_DMA_SetChannelPriorityLevel(DMA2_Channel4, DMA2_Channel4, LL_DMA_PRIORITY_HIGH);
LL_DMA_SetMode(DMA2_Channel4, DMA2_Channel4, LL_DMA_MODE_NORMAL);
LL_DMA_SetPeriphIncMode(DMA2_Channel4, DMA2_Channel4, LL_DMA_PERIPH_NOINCREMENT);
LL_DMA_SetMemoryIncMode(DMA2_Channel4, DMA2_Channel4, LL_DMA_MEMORY_INCREMENT);
LL_DMA_SetPeriphSize(DMA2_Channel4, DMA2_Channel4, LL_DMA_PDATAALIGN_BYTE);
LL_DMA_SetMemorySize(DMA2_Channel4, DMA2_Channel4, LL_DMA_MDATAALIGN_BYTE);
/* USART6 interrupt Init */
// ...
}
As far as I can see in the release notes of the newer STM32CubeMX this problem has not been fixed yet.
2024-11-27 05:46 AM - edited 2024-11-27 05:47 AM
Hello @SOfne.1
There is a new STM32CubeMx release v6.13 with enhancement and fixes.
Please try this latest release and keep me informed about your updates.