Skip to main content
MMust.5
Senior
May 21, 2022
Solved

Why does setting pin 0 of port A to analog mode cause an error?

  • May 21, 2022
  • 2 replies
  • 1621 views

STM32F407VGT6

Why is access to the Microcontroller broken after this code?

The MODER register after this code should look like this: 00000000000000000000000000000011

this is Analog mode for pin 0 of port A.

int main(void)

{

RCC->AHB1ENR|=RCC_AHB1ENR_GPIOAEN;

GPIOA->MODER=0x3;

 while (1)

 {

 }

}

0693W00000NqOKGQA3.png 

Same but with port B or C does not throw an error

RCC->AHB1ENR|=RCC_AHB1ENR_GPIOBEN;

GPIOB->MODER=0x3;

-----------------------------

RCC->AHB1ENR|=RCC_AHB1ENR_GPIOCEN;

GPIOC->MODER=0x3;

 ----------------------------

Port A is compatible with Analog mode

A user button is connected to pin 0 of Port A, but it is not pressed, which means it does not interfere with the execution of the code.

This topic has been closed for replies.
Best answer by Piranha

You are disabling the SWD pins PA13 and PA14. Look at the GPIOx_MODER reset values at the reference manual.

2 replies

Piranha
PiranhaBest answer
Principal III
May 21, 2022

You are disabling the SWD pins PA13 and PA14. Look at the GPIOx_MODER reset values at the reference manual.

MMust.5
MMust.5Author
Senior
May 21, 2022

Exactly)) Thanks.