1597 views|3 replies

297

Posts

0

Resources
The OP
 

UART1 idle interrupt exception occurs when STM32F407VE replaces STM32F429VI [Copy link]

The price of STM32F429VI is too high, so I replaced it with STM32F407VE. I did not modify the program and tested UART, SPI, and CAN, all of which were normal. After using it for a while, I found that UART1 idle interrupt can only receive one byte, while UART2 and 3 can receive normally with the same settings;
the initialization is as follows:
if(uartHandle->Instance==USART1)
{
/* USER CODE BEGIN USART1_MspInit 0 */

/* USER CODE END USART1_MspInit 0 */
/* USART1 clock enable */
__HAL_RCC_USART1_CLK_ENABLE();

__HAL_RCC_GPIOA_CLK_ENABLE();
/**USART1 GPIO Configuration
PA9 ------> USART1_TX
PA10 ------> USART1_RX
*/
GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

/* USART1 DMA Init */
/* USART1_RX Init */
hdma_usart1_rx.Instance = DMA2_Stream2;
art1_rx.Init.Channel = DMA_CHANNEL_4;
hdma_usart1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
hdma_usart1_rx.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_usart1_rx.Init.MemInc = DMA_MINC_ENABLE;
hdma_usart1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
hdma_usart1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
hdma_usart1_rx.Init.Mode = DMA_NORMAL;
hdma_usart1_rx.Init.Priority = DMA_PRIORITY_LOW;
_usart1_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
if (HAL_DMA_Init(&hdma_usart1_rx) != HAL_OK)
{
Error_Handler();
}

__HAL_LINKDMA(uartHandle,hdmarx,hdma_usart1_rx);

/* USART1_TX Init */
hdma_usart1_tx.Instance = DMA2_Stream7;
hdma_usart1_tx.Init.Channel = DMA_CHANNEL_4;
hdma_usart1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
hdma_usart1_tx.Init.PeriphInc = DMA_PINC_DISABLE; hdma_usart1_tx.Init.MemInc =
DMA_MINC_ENABLE; ma_usart1_tx.Init.PeriphDataAlignment
= DMA_PDATAALIGN_BYTE;
hdma_usart1_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
hdma_usart1_tx.Init.Mode = DMA_NORMAL;
hdma_usart1_tx.Init.Priority = DMA_PRIORITY_LOW;
hdma_usart1_tx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
if (HAL_DMA_Init(&hdma_usart1_tx) != HAL_OK)
{
Error_Handler();
}

__HAL_LINKDMA(uartHandle,hdmatx,hdma_usart1_tx);

/* USART1 interrupt Init */
HAL_NVIC_SetPrior ity(USART1_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(USART1_IRQn);
/* USER CODE BEGIN USART1_MspInit 1 */

/* USER CODE END USART1_MspInit 1 */
}

The reception processing is as follows:

__HAL_UART_CLEAR_IDLEFLAG(&huart1);
HAL_UART_DMAStop(&huart1);
temp = huart1.hdmarx->Instance->NDTR;
Usart1Type1.rx_len = UART_RECE IVE_LEN - temp;
Usart1Type1.receive_flag = 1;
HAL_UART_Receive_DMA(&huart1, Usart1Type1.usartDMA_rxBuf, UART_RECEIVE_LEN);
__HAL_DMA_SET_COUNTER(huart->hdmarx, UART_RECEIVE_LEN);
__HAL_DMA_ENABLE(huart->hdmarx);

It’s so strange!

Use STM32CubeMX to produce V1.1 software, select STM32F407VE as MCU, generate code to test UART1 IDEL+DMA reception, the UART1 reception problem still exists; change keil to V5.29 test-> USART1 reception data situation still exists;

This post is from stm32/stm8

Latest reply

[attach]618030[/attach] [attach]618031[/attach]I wonder if the problem lies here: The maximum speed of UART1 in the two chips is different, 429 is higher than 407, so sometimes there will be problems. This can also explain why UART2 and UART3 are normal, because they use different sources, 1 is APB2, 2,3 are APB1. You may need to change the RCC settings.   Details Published on 2022-6-30 02:12
 

148

Posts

0

Resources
2
 

I wonder if the problem lies here:

The maximum speed of UART1 in the two chips is different, 429 is higher than 407, so sometimes there will be problems.

This can also explain why UART2 and UART3 are normal, because they use different sources, 1 is APB2, 2,3 are APB1.

You may need to change the RCC settings.

This post is from stm32/stm8
 
 

297

Posts

0

Resources
3
 

OK, I configured it to use the internal crystal oscillator and multiply it to 168M. The strange thing is that it worked fine before, but after a while it started to have problems.

This post is from stm32/stm8
 
 

297

Posts

0

Resources
4
 

After re-updating, everything works again, and I changed a USB to RS232 cable. The problem is that the previous USB to RS232 cable works fine on the STM32F429.

This post is from stm32/stm8
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list