Skip to main content
arnold_w
Senior II
May 3, 2023 1:52 PM UTC
Solved

Once in a while STM32F446 is unable to drive pin PA0 high or low

I'm working with the STM32F446-microcontroller and once in a while after power-up the microcontroller is unable to drive pin PA0 high or low and I also suspect that it can't drive PA8, configured as an I2C-clock, either when this problem occurs. There is no issue with input sensing on PA0, i.e. reading GPIOx->IDR always returns the correct result. Also, I'm able to communicate with a custom-made PC-application via CAN-bus and I can upgrade firmware on the microcontroller using a custom-made bootloader, but it won't get PA0 out of the non-controllable state. A software reset doesn't help either, the only solution is to disconnect power for about 5-6 seconds and then things work fine again. Can anybody think of anything I can do to solve this? Are there any registers I can play with to try get PA0 controllable again?

This topic has been closed for replies.
waclawek.jan
waclawek.janBest answer
Super User
May 3, 2023 4:00 PM UTC

What hardware? What is connected to PA0?

Read out and check/post content of GPIO registers - compare between working and non-working states.

[EDIT] PA0 is RTC_AF2, and RTC (probably) overrides GPIO settings, so in case of problems check also RTC registers content. Could this be a case of VBAT brownout issue? Tell us about how VBAT is connected and how exactly is the board powered, and also how the option bytes are set.

JW

5 replies

waclawek.jan
waclawek.janBest answer
Super User
May 3, 2023 4:00 PM UTC

What hardware? What is connected to PA0?

Read out and check/post content of GPIO registers - compare between working and non-working states.

[EDIT] PA0 is RTC_AF2, and RTC (probably) overrides GPIO settings, so in case of problems check also RTC registers content. Could this be a case of VBAT brownout issue? Tell us about how VBAT is connected and how exactly is the board powered, and also how the option bytes are set.

JW

arnold_w
arnold_wAuthor
Senior II
May 4, 2023 12:57 PM UTC

I'm using the STM32F446RET6 microcontroller on our own PCB. All the GPIOA-related registers contained correct values, but a bunch of RTC registers (ALRMAR, TR, DR, CR, ISR,PRER, etc) contained seemingly random values. The option bytes were all ok. The power-up sequence is not so pretty. I added:

  RCC->BDCR |= 0x00010000;

  PWR->CR  |= 0x00000100;

first thing in main() and then the problem disappeared. I now plan to add those two lines in ALL our products. Thanks a lot for your help and for your excellent blog webpage!

waclawek.jan
Super User
May 4, 2023 1:04 PM UTC

Thanks for letting us know.

Do you have VBAT connected to VDD on your PCB?

JW

arnold_w
arnold_wAuthor
Senior II
May 4, 2023 1:09 PM UTC

Yes, VBAT is routed to 3.3V, just like all the VDD pins.

waclawek.jan
Super User
May 4, 2023 2:15 PM UTC

Thanks.

JW