Question
Output Compare Mode for STM32F407 Discovery board
Hi,
I am working on STM32F4 discovery board and I am trying to use output compare mode.
and I have written the following code using peripheral registers.
The application is Toggle the LED for every 1sec when output compare is matched.
Here is the code. But it is not working. Can any one help me what might be the problem
/*This Program demonstrate the working of General Purpose Timer using Output Compare @1Hz Delay*/
#include "stm32f4xx.h" //Header File for STM32F4 device
int main(void)
{
//
RCC->AHB1ENR |=1; //Enable GPIOA Port Clock
GPIOA->MODER|= 0X800 ; //Configure I/O direction for PA5 as Alternatefunction 0100 0000 0000
GPIOA->AFR[0]|=0X00100000;
RCC->APB1ENR|=1;
TIM2->PSC=1600-1;
TIM2->ARR=10000-1;
TIM2->CCMR1=0X30;
TIM2->CCR1=0;
TIM2->CCER|=1;
TIM2->CNT=0;
TIM2->CR1=1;
while(1)
{
}
return 0;
}