2017-04-28 07:34 PM
Hello,
I am trying to programming my board using registers in Ref. Man. I used TI MSP430. Therefore, i am familliar with registers. But, when i try to blink the leds under the button's control, it is not easy for me. Here is the part of my code;
int main(void){
RCC -> AHB1ENR |= 0x00000009; GPIOD -> MODER |= 0x55000000; GPIOA -> MODER &= 0x00000000; GPIOD -> OTYPER |= 0x00000000; GPIOA -> OTYPER |= 0x00000000; GPIOD -> OSPEEDR |= 0x55000000; GPIOA -> OSPEEDR |= 0x00000001; GPIOD -> PUPDR |= 0x00000000; GPIOA -> PUPDR |= 0x00000001;In the debug mode, after the bold line, i get this error;
What is the reason for that error? Did i make somehing wrong?
There is also one more thing. I try to read the button's value with ''GPIOA -> IDR'' register. I writed that code below to read;
if(GPIOA -> IDR == 0x00000001 )
Is it right? Because, in the debug mode, the IDR value is not change when i press the button. IDR value always is 0x000085CF. Thats why the code cannot detect if it is pressed.
Best regards.
#button #led #register2017-04-30 04:41 PM
The debug pins are on GPIOA and you must not change their MODER nor AFRL/AFRH settings, if you want to use them.
The GPIOA->IDR value will be 0x0001 if all the GPIOA pins are low except PA0.
JW
2017-05-03 07:36 PM
Thank you so much.
I decided to use the registers in stm32f407xx.h file. It become easier in that way.
Best regards