AnsweredAssumed Answered

Counter TIM4

Question asked by mattal.karl on Feb 13, 2012
Latest reply on Feb 17, 2012 by mattal.karl
Hi! I have a probem with a simple software that I've wrote to learn to use timers.
This is the code that I've used.

#include "stm8l15x.h"


main()
{
     


  TIM4_DeInit();
     TIM4_TimeBaseInit(TIM4_Prescaler_2048, 200);
     TIM4_Cmd(ENABLE);
     
     
     GPIO_DeInit(GPIOC);
     GPIO_DeInit(GPIOE);
     GPIO_Init(GPIOC, GPIO_Pin_7,GPIO_Mode_Out_PP_High_Fast);
  GPIO_Init(GPIOE, GPIO_Pin_7,GPIO_Mode_Out_PP_High_Fast);     
     
     while(1) {
          
     if (TIM4_GetCounter() == 0) GPIO_SetBits(GPIOC, GPIO_Pin_7);
     else GPIO_ResetBits(GPIOC, GPIO_Pin_7);
     
     if (TIM4_GetCounter() > 0) GPIO_SetBits(GPIOE, GPIO_Pin_7);
     else GPIO_ResetBits(GPIOE, GPIO_Pin_7);
     
          
     }
}

Practically the counter do not start, his value is stoped at 0x00.
Can you help me? :)

P.S.= Sorry for my bad english....

Outcomes