Skip to main content
This topic has been closed for replies.

9 replies

S.Ma
Principal
Jul 27, 2020 3:13 PM UTC

go to debug mode and look at usart, gpio and sys/rcc registers for clock enable. track down the issue

INaka.1
INaka.1Author
Associate III
Jul 27, 2020 7:12 PM UTC

The register of USART1 always zero except for the ISR=c0

TDK
Jul 27, 2020 3:41 PM UTC

Enable the usart1 clock. Generate code with stm32cubemx to do this for you. Show your code.

"If you feel a post has answered your question, please click ""Accept as Solution""."
INaka.1
INaka.1Author
Associate III
Jul 27, 2020 7:09 PM UTC

Well... The clock has been enabled at 120MHz. Please, don't repair on my code. I'm a beginner.

njedwardz
Visitor II
Nov 23, 2020 4:58 PM UTC

I am encountering the same error; all other UARTs are working, using Nucleo-L4R5ZI. USART1 CR1 remains at 0, even after the MODIFY_REG instruction is issued during initialization. I suspect that this has something to do with USART1 being on APB2 while all other USARTs are on APB1.

Tesla DeLorean
Guru
Nov 23, 2020 5:12 PM UTC

If all the USART's registers are ZERO, then the clock is likely not properly enabled. Try ENABLING it

Inspect the registers for the RCC and make a determination if it relates to APB1 vs APB2

Last time I check this was coded properly for the L4

__USART1_CLK_ENABLE();

__HAL_RCC_USART1_CLK_ENABLE

#define __HAL_RCC_USART1_CLK_ENABLE()     do { \

                         __IO uint32_t tmpreg; \

                         SET_BIT(RCC->APB2ENR, RCC_APB2ENR_USART1EN); \

                         /* Delay after an RCC peripheral clock enabling */ \

                         tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_USART1EN); \

                         UNUSED(tmpreg); \

                        } while(0)

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
njedwardz
Visitor II
Nov 23, 2020 6:26 PM UTC

By manually calling __HAL_RCC_USART1_CLK_ENABLE(), I can see that USART1 CR1 is now changing to the expected value (one would not think this step necessary, as this happens in HAL_UART_MspInit as generated by CubeMx prior to any configuration being attempted).

I am still not getting transmissions through USART1. I can confirm that all registers are identical between USART1 and USART2; USART2 is working as expected. I have confirmed that the pin I am using for USART1 is functional when used as a GPIO in output mode.

The line does not idle high as expected; it is just constantly low.

I can confirm that USART1 is enabled in APB2ENR and NOT in reset state in APB2RSTR.

njedwardz
Visitor II
Nov 23, 2020 8:31 PM UTC

For all who are experiencing this issue, upgrading to the latest version of STM32CubeIDE (1.5.0) successfully resolved my issue. I was previously using 1.3.0. I presume this error was caused by some issue in the CubeMX-generated initialization code.

INaka.1
INaka.1Author
Associate III
Nov 25, 2020 8:28 PM UTC

Hello dear friend!!!

I 've tried the suggestion of ST enginneer and used the the old version of STM32 CUBEMX Version 6.0.0

and the LPUSART worked properly.

Best regards