Prototype21
Junior Member level 1
Hello Guys,
I am new to arm development. I have written the below code for my STM32F446RE Nucleo board. All I am trying to do is turn on Pin PA3, Pin PA2 and onboard LED Pin PA5. The code compiled and flashed successfully. But no success in turning on those pins even after several retries. Am I missing any register?? Need some help guys.
I am new to arm development. I have written the below code for my STM32F446RE Nucleo board. All I am trying to do is turn on Pin PA3, Pin PA2 and onboard LED Pin PA5. The code compiled and flashed successfully. But no success in turning on those pins even after several retries. Am I missing any register?? Need some help guys.
Code:
// Enable clock access to the port.
// Set pin mode
// Set pin as o/p
#include "stm32f4xx.h" // Device header
#define RED (1U << 3) // PIN PA3
#define VIOLET (1U << 2) // PIN PA2
#define GREEN (1U << 2) // PIN PA5 Onboard LED
#define GPIOA_CLOCK (1U << 0)
#define RED_OUT_BIT (1U << 6) // General purpose output mode, no alternate function, no analog, no input mode
#define VIOLET_OUT_BIT (1U << 4) // General purpose output mode, no alternate function, no analog, no input mode
#define GREEN_OUT_BIT (1U << 10) // General purpose output mode, no alternate function, no analog, no input mode
int main() {
RCC -> AHB1ENR |= GPIOA_CLOCK;
GPIOA -> MODER |= RED_OUT_BIT | VIOLET_OUT_BIT | GREEN_OUT_BIT;
while(1) {
GPIOA -> ODR |= RED | VIOLET | GREEN;
}
}