cancel
Showing results for 
Search instead for 
Did you mean: 

Programming STM32F407VG Discovery Board in Register Level

Recep Onur Y?ld?z
Associate
Posted on April 29, 2017 at 04:34

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;

                                    0690X00000606ZmQAI.png

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 #register
2 REPLIES 2
Posted on May 01, 2017 at 01:41

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

Posted on May 04, 2017 at 02:36

Thank you so much.

I decided to use the registers in stm32f407xx.h file. It become easier in that way.

Best regards