The most basic thing one would do with an MCU would be how to control the IO pins right? So how do we program the GPIO pins on STM32F4Discovery board?
Let's take a look at it now,
First and foremost we need to add stm32f4xx_gpio.h and stm32f4xx_rcc.h header files to be included in the project.
Once that is done we must enable clock to the port (whichever port you would like to use)
Each peripheral bus is detailed in the datasheet and we can use this information to enable system clock programmatically based on our application.
Then we have to set parameters for configuring GPIO pins
The various options are self explanatory.You can adjust the settings based on your application.
Now lets try to toggle pin14 from PORTD which is an onboard LED on our discovery board.
We've done it! Now you can compile it and see the onboard LED blinking ON and OFF!
So the final code looks something like
Let's take a look at it now,
First and foremost we need to add stm32f4xx_gpio.h and stm32f4xx_rcc.h header files to be included in the project.
Once that is done we must enable clock to the port (whichever port you would like to use)
Each peripheral bus is detailed in the datasheet and we can use this information to enable system clock programmatically based on our application.
Then we have to set parameters for configuring GPIO pins
The various options are self explanatory.You can adjust the settings based on your application.
Now lets try to toggle pin14 from PORTD which is an onboard LED on our discovery board.
We've done it! Now you can compile it and see the onboard LED blinking ON and OFF!
So the final code looks something like
Comments
Post a Comment