2019-10-21 07:22 PM
step 1: initialize clock
step 2: set pins to output
step 3: set corresponding 'set' bits to 1 in BSRR register
int main(){
//enable clock for necessary ports
//clock for leds: port port B, pins 0, 1, 5
RCC->AHB2ENR |= RCC_AHB2ENR_GPIOBEN;
//RCC->AHB2ENR |= RCC_AHB2ENR_GPIOCEN;
//decide which pin in input or output
GPIOB->MODER |= GPIO_MODER_MODE0_0;
GPIOB->MODER |= GPIO_MODER_MODE1_0;
GPIOB->MODER |= GPIO_MODER_MODE5_0;
GPIOB->BSRR |= GPIO_BSRR_BS0;
GPIOB->BSRR |= GPIO_BSRR_BS1;
GPIOB->BSRR |= GPIO_BSRR_BS5;
};
2019-10-21 07:59 PM
Perhaps you could use a debugger, and inspect the registers?
You only need to write BSRR, no need to RMW
If you want to use RMW access ODR
Avoid exiting main()
2019-10-23 07:44 PM
What do you mean RMW? Are you saying I dont have to enable the clocks for gpio B?