cancel
Showing results for 
Search instead for 
Did you mean: 

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

MMust.5
Senior II

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Piranha
Chief II

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

View solution in original post

2 REPLIES 2
Piranha
Chief II

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

MMust.5
Senior II

Exactly)) Thanks.