STM32 Register Value Doesn't Change

1.8k views Asked by At

Problem Definition

Board: STM32F407

Hello all,

I am trying to change any register value. But it doesn't change. For example if we look GPIOB port's MODER register it has default "0x0000 0280" value for port B. This means that MODER registers 7 and 9 have a value of 1, other MODER registers have a value of 0. I am trying to change 1 to 0 for MODER 7 register. I am sharing the simple one-line I did below.

GPIOB ->MODER &= ~(1 << 7);

DEBUG PROCESS enter image description here

I am debugging the code. And register value doesn't change. I tried for some another register to see whether it is done or not. Bu it didn't. What can I do, what is my fault.

Thank in advance

2

There are 2 answers

1
0___________ On

You need to enable the GPIOB clock in one of the RCC regesters first.

If the clock is disabled the digital part of the peripheral is disabled too.

0
V B On

I faced the same issue. And the solution is you forgot to enable the clock of the peripheral. RCC->AxBxENR |= (1<<BITPOSITION);