2019-12-15 04:03 AM
Hello , I`m newbie to STM32 processors , i was working on AVR .....
It has been 3 days since i was trying to find out what is wrong with my registers` definition .. in this photo i defined RCC_APB2ENR and i did try to set a specific bit , but the result is that the bit is not set .. can anyone help me with that?
2019-12-15 04:47 AM
It should work. Debugger problems?
Another question. Register definitions are probably the only useful "code" from ST. Why you are redefining those?
2019-12-15 04:49 AM
Well it is not working and i flashed the code onto the controller and the led connected to a specific GPIOD Pin didn`t turn on ...
and i am redefining these again to get my hand used to it
2019-12-15 05:08 AM
Welcome to pointer arithmetic in C. And operators precedence.
Casting a value to another type is an unary operator, it has higher precedence as binary operators like addition. So 0x40023800 is converted to a pointer to uint32_t first, and 0x44 gets added to this pointer. By the rules of C pointer arithmetic, you'll get 0x40023800 + 0x44*sizeof(uint32_t).
To fix it, just ensure that the offset gets added to the base first by the rules of integer arithmetic, and cast to pointer afterwards.
((volatile uint32_t *)(0x40023800 + 0x44))
2019-12-15 05:14 AM
Thank youuuuuu <3 , I had a doubt about that .... thank youuu again <3