2013-02-20 10:36 PM
Hello all,
I have been on other forums and no-one has been able to help me so far. I am implementing a timer in a stm32f303 microcontroller. Below is the code that I am using to start it. Can anyone give a suggestion on why the CNT register doesn't count?TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
int main ( void )
{ //Enable SYSCFG clock RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);//Timer clock
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE); //Time base configuration TIM_TimeBaseStructInit(&TIM_TimeBaseStructure); TIM_TimeBaseStructure.TIM_Period = 9999; TIM_TimeBaseStructure.TIM_Prescaler = 99; TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInit(TIM4, &TIM_TimeBaseStructure);//TIM Interrupts enable
TIM_ITConfig(TIM4, TIM_IT_Update, ENABLE); TIM_Cmd(TIM4, ENABLE); while(1); #stm32f3032013-02-21 03:53 AM
Where are you observing it not counting?
Make sure not to use a simulator, ie run on actual device, check debug target tab Can you set up one of the channels to output via a pin, or toggle a pin in the interrupt? Are you enabling the NVIC and handling the interrupt?