STM32F401RE Board PWM doesn't work on this port
Hi everyone
I have an STM32F401RE board and I have an LED from pin PB6 to GND.
In the same project that this snippet code below comes from I have a PWM running on PA5 pin and it is blinking.
I have been at this all night and I can't figure out why PB6 is not blinking with the PWM. Here is the code. I am using Timer5 and as far as I know the AFR[0] is set correctly.
I hope anybody can see something wrong cause if not then I really don't know what to do : /
Also another question is.. if I want to start and stop the PWM output on that pin instantly and on a regular basis what would be the best way to do so? Disable the PWM or reset the PORT MODE to something else?
Thanks
void step_init(){
RCC->AHB1ENR |= (1 << 2); //Enable clock access to port B
GPIOB->AFR[0] |= (1<<25); //Set PB6 for TIM5
GPIOB->MODER |= (1<<13); //Sets oub PB6 for alternate functions
//Timer Setup
RCC->APB1ENR |= (1<<3); //Enables Timer5
TIM5->PSC = 1600-1; //Prescaker of 1600
TIM5->ARR = 10000; //Reload at 10000 counts
TIM5->CNT = 0; //
TIM5->CCMR1 = 0b1100100; //OC1M PWM Mode1 and Output compare 1 preload enable
//TIM5->CCMR1 = 0x0060; // Enable PWM mode //1100000
TIM5->CCER |= 1; //Enable PWM ch1
TIM5->CCR1 = 5000; //50%DC
TIM5->CR1 |= 1; //Enable
}