2020-11-25 02:21 AM
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:
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
Solved! Go to Solution.
2020-11-27 12:06 AM
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
2020-11-27 12:06 AM
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
2020-11-27 12:24 AM
Hello @AT.1 ,
Welcome to the STM32 Community :smiling_face_with_smiling_eyes:.
Thanks for sharing the solution! It is much appreciated and it should be helpful for the Community.
Imen