Timer(output compare mode) not working of stm32f411re
I am using a stm32f411re nucleo board , i am trying to configure the Tim2_ch1 in output compare mode .
i have written the code by referring the reference manual
code:
//PA5:TIM2_CH1
// clock frequency:16Mhz
#include "stm32f4xx.h" // Device header
// toggle led at 1hz using TIM2 output COMPARE MODE
int main(void)
{
RCC->AHB1ENR |=1;
GPIOA->MODER |=0X800; //PA_5 is configured in alternate function mode
GPIOA->AFR[0] |=0X00100000; // Tim2_ch1 is assigned to PA_5
//TIM2 OUTPUT COMPARE CONFIG
RCC->APB1ENR |=1;
TIM2->PSC |=1600-1;
TIM2->ARR |=10000-1; //clock frequency is divided by prescalar and auto reload
TIM2->CCMR1 |=0X30;
TIM2->CCR1 |=0;
TIM2->CCER |=1;
TIM2->CNT |=0;
TIM2->CR1 |=1;
while(1)
{}
}
This code is not working ,is there any issue with the code?
