2023-05-30 06:43 AM - edited 2023-11-20 04:21 AM
I attempt to use the ST example code 'UART_TwoBoards_ComPolling' that comes with the STM32CubeF1 library. (All ST examples are very helpful, thank you.)
Development environment used:
* Library: STM32Cube_FW_F1_V1.8.5.
* Hardware: two NUVLEO-F103RB boards (one for UART1_TX, one for UART1_RX).
* IDE: STM32CubeIDE Version: 1.12.1.
The example code is built two times, both for the TX Nucleo and for the RX Nucleo. That means, the UART1 peripherals on both boards are configured the same.
Problem:
The UART1_TX function does not seem to work in the function HAL_UART_Transmit():
/*##-2- Start the transmission process ######### */
if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer, TXBUFFERSIZE, 5000)!= HAL_OK)
{
Error_Handler();
}
In particular, the IDE debugger shows that the UART data register (DR) does not change during the following char assignment, as the DR value is always shown as 0. See the Debugger screenshot at the bottom.
else
{
huart->Instance->DR = (uint8_t)(*pdata8bits & 0xFFU);
pdata8bits++;
}
huart->TxXferCount--;
Increasing the TX-buffer pointer (pdata8bits++) and the counter (TxXferCount++) works, so the correct characters should be written to the UART1->DR.
Question:
* How to confirm that DR is actually being updated?
* Should this work in Debug mode?
* Is the DR cleared immediately after transmitting the data?
Thank you!
Solved! Go to Solution.
2023-05-30 06:46 AM
to troubleshoot the problem with the UART example code in the STM32F1 HAL library.
If you have checked all of these things and the UART is still not transmitting data, you may need to contact the manufacturer of the STM32F1 HAL library for further assistance.
Here are some additional things you can check:
2023-05-30 06:46 AM
to troubleshoot the problem with the UART example code in the STM32F1 HAL library.
If you have checked all of these things and the UART is still not transmitting data, you may need to contact the manufacturer of the STM32F1 HAL library for further assistance.
Here are some additional things you can check:
2023-05-30 07:01 AM
@MOhamed_Mehery thank you for your response. How to check if the UART is in a fault state?
2023-05-30 09:53 PM
Check the registers
2023-06-23 02:51 PM
The DR register is NOT a memory, it is a window on the logic of the UART.
A write to DR goes into a buffer and shift register for transmission.
What you read from DR is a similar arrangement on the RECEIVE side, so you're not looking at the data you wrote unless the pins externally loop back.
Also looking at DR in the Debugger will clear and change bit settings in SR, which reflect that received data has been read, and to now reflect that new data is available, or not.
You can read error and fault states, like framing, parity and noise, by inspecting SR. It is recommended that you have your code read this into a variable, and you then inspect the variable, in RAM