cancel
Showing results for 
Search instead for 
Did you mean: 

Issue in debug mode when use Uart

AT.1
Associate

Hello,

I'm creating application with STM32F072, with ADC DMA, USB, Timers and Uart.

Last one is used to communicate with PC but i verify a strange behavior.

First of all general information:

  • generating this software with STM32cubeMx.
  • using IDE openstm32
  • priority level USB = 0
  • priority level TIM3 = 1
  • priority level DMA = 2
  • priority level UART = 3

The strange behavior is present when i'm debugging application for checking uart peripherals.

I sent chars from MCU to PC, when these chars arrived on minicom see chars differets.

When PC sent chars to MCU, MCU goes in error for noise.

This happend in debug mode.

In Run mode ( same configuration debug) this behavior not is present yet.

Can you explain what i missed?

Thank you in advanced

Andrea

1 ACCEPTED SOLUTION

Accepted Solutions
AT.1
Associate

Hello,

i solved this issue.

I found the problemi is in USART inizialization parameters and clock source .

Clock source chaging:

Before with issue

 PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK1;

After without issue

 PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_HSI;

USART inizialization parameters chaging:

Before with Issue:

huart1.Instance = USART1;

 huart1.Init.BaudRate = 38400;

 huart1.Init.WordLength = UART_WORDLENGTH_8B;

 huart1.Init.StopBits = UART_STOPBITS_1;

 huart1.Init.Parity = UART_PARITY_NONE;

 huart1.Init.Mode = UART_MODE_TX_RX;

 huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;

 huart1.Init.OverSampling = UART_OVERSAMPLING_16;

 huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;

 huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;

After without issue:

huart1.Instance = USART1;

 huart1.Init.BaudRate = 38400;

 huart1.Init.WordLength = UART_WORDLENGTH_8B;

 huart1.Init.StopBits = UART_STOPBITS_1;

 huart1.Init.Parity = UART_PARITY_NONE;

 huart1.Init.Mode = UART_MODE_TX_RX;

 huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;

 huart1.Init.OverSampling = UART_OVERSAMPLING_16;

 huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;

huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_RXOVERRUNDISABLE_INIT|UART_ADVFEATURE_DMADISABLEONERROR_INIT;

 huart1.AdvancedInit.OverrunDisable = UART_ADVFEATURE_OVERRUN_DISABLE;

 huart1.AdvancedInit.DMADisableonRxError = UART_ADVFEATURE_DMA_DISABLEONRXERROR;

Now in Debugging i can see correct bytes trasmit and receive on PC and in debug watch live IDE expression.

B.R.

Andrea

View solution in original post

2 REPLIES 2
AT.1
Associate

Hello,

i solved this issue.

I found the problemi is in USART inizialization parameters and clock source .

Clock source chaging:

Before with issue

 PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK1;

After without issue

 PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_HSI;

USART inizialization parameters chaging:

Before with Issue:

huart1.Instance = USART1;

 huart1.Init.BaudRate = 38400;

 huart1.Init.WordLength = UART_WORDLENGTH_8B;

 huart1.Init.StopBits = UART_STOPBITS_1;

 huart1.Init.Parity = UART_PARITY_NONE;

 huart1.Init.Mode = UART_MODE_TX_RX;

 huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;

 huart1.Init.OverSampling = UART_OVERSAMPLING_16;

 huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;

 huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;

After without issue:

huart1.Instance = USART1;

 huart1.Init.BaudRate = 38400;

 huart1.Init.WordLength = UART_WORDLENGTH_8B;

 huart1.Init.StopBits = UART_STOPBITS_1;

 huart1.Init.Parity = UART_PARITY_NONE;

 huart1.Init.Mode = UART_MODE_TX_RX;

 huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;

 huart1.Init.OverSampling = UART_OVERSAMPLING_16;

 huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;

huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_RXOVERRUNDISABLE_INIT|UART_ADVFEATURE_DMADISABLEONERROR_INIT;

 huart1.AdvancedInit.OverrunDisable = UART_ADVFEATURE_OVERRUN_DISABLE;

 huart1.AdvancedInit.DMADisableonRxError = UART_ADVFEATURE_DMA_DISABLEONRXERROR;

Now in Debugging i can see correct bytes trasmit and receive on PC and in debug watch live IDE expression.

B.R.

Andrea

Imen.D
ST Employee

Hello @AT.1​ ,

Welcome to the STM32 Community 😊.

Thanks for sharing the solution! It is much appreciated and it should be helpful for the Community.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen