1

I tried to access RCC_APB2ENR register as a first step to blink green led on stm32nucleo f103rb

then I added 0x0C to 0x40010800(RCC base address).

The expected result was 0x4001080C but the actual result was 0x40010830!!!

It seems 0x0C was left shifted twice but I can't understand why this thing happened.

And even in Ubuntu, the same thing happened.

please let me know

board : stm32 nucleo f103rb IDE : uVision 5

김정우
  • 23
  • 4

1 Answers1

4

RCC_BASE points to unsigned int. On your platform size of this type is 4 bytes.

While adding or subtraction to pointers you are increasing (or decreasing) address by operand multiplied by size of element.

For details looks Pointer Arithmetic

tymmej
  • 96
  • 2