Skip to main content
jeff.lee
Associate II
December 15, 2018
Question

does not work uart RX DMA after baudrate change from 9600 to 115200 during run mode

  • December 15, 2018
  • 3 replies
  • 1198 views

chip : stm32L433CCUX. source code is made by cubeMX automatically.

below my scenarios.

1.stm32l4 starts with uart baud rate 9600. and start with uart DMA.

2.communicate with other gps module by uart baud rate is 9600. for gps configuration

gps uart baud rate change is 115200.

3.stm32l4 uart baud rate is change 115200.

my problem is after uart baud rage changed with 115200. the uart DAM is not work.

i check the " the huart3.hdmarx->Instance->CNDTR" number.

if uart RX DMA is received data, huart3.hdmarx->Instance->CNDTR will be changed.

but no changed.

also, i set up circular mode with uart rx dma.

my code below

 /* Initialize all configured peripherals */

 // MX_GPIO_Init();

 MX_DMA_Init();

 MX_USART3_UART_Init(); // baud rate 9600

 MX_I2C2_Init();

 MX_USB_DEVICE_Init();

 MX_RTC_Init();

 /* USER CODE BEGIN 2 */

HAL_UART_Receive_DMA(&huart3,UART_Receive_data,sizeof(UART_Receive_data));

CLEAR_BIT(huart3.Instance->CR1, USART_CR1_PEIE);

CLEAR_BIT(huart3.Instance->CR3, USART_CR3_EIE);

void gpsConfiguration(void)

{

#if 1

  for(int i=0;i<28;i++)

  {

   //HAL_UART_Transmit(&huart3,&BDrateHex115200[i],28,10);

   HAL_UART_Transmit_DMA(&huart3,&BDrateHex115200[i],28);

  }

  HAL_Delay(1000);

  huart3.Instance = USART3;

  huart3.Init.BaudRate = 115200; //changed 115200

  huart3.Init.WordLength = UART_WORDLENGTH_8B;

  huart3.Init.StopBits = UART_STOPBITS_1;

  huart3.Init.Parity = UART_PARITY_NONE;

  huart3.Init.Mode = UART_MODE_TX_RX;

  huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;

  huart3.Init.OverSampling = UART_OVERSAMPLING_16;

  huart3.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;

  huart3.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;

  if (HAL_UART_Init(&huart3) != HAL_OK)

  {

   _Error_Handler(__FILE__, __LINE__);

  }

#endif

}

This topic has been closed for replies.

3 replies

Tesla DeLorean
Guru
December 15, 2018

Make sure you clear any underrun, framing or noise type errors that might be blocking the USART reception.

if (USART3->ISR & USART_ISR_ORE) // Overrun Error

USART3->ICR = USART_ICR_ORECF;

if (USART3->ISR & USART_ISR_NE) // Noise Error

USART3->ICR = USART_ICR_NCF;

if (USART3->ISR & USART_ISR_FE) // Framing Error

USART3->ICR = USART_ICR_FECF;

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
jeff.lee
jeff.leeAuthor
Associate II
December 15, 2018

hello thanks your comment.

can you explain more?

where these code is programmed ? what api?

i have to code in HAL_UART_RxCpltCallback??

Tesla DeLorean
Guru
December 15, 2018

>>where these code is programmed ?

The obvious place would be after you've changed the baud rate in order to clear any errors that has induced.

>>these code are already in the UART_DMAReceiveCplt.

That's only going to help if it gets there, and you've already stated that it stopped working.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
jeff.lee
jeff.leeAuthor
Associate II
December 15, 2018

these code are already in the UART_DMAReceiveCplt.

adrian
Associate III
December 15, 2018

What clock is the UART being driven from?