2014-12-21 09:18 AM
set up the prescaler and period, and let it run.
then at certain point, I want to set the counter to some specific value. however, it seems that setting counter using TIM1_SetCounter(), can actually clear the prescaler setting(TIM1->PSCR = 0). I wasn't sure whether this is a silicon bug or not. would anyone make a test about this problem with his STM8S? and solution: set the desired prescaler immediately after SetCounter(), like my example below.void
setcntr()
{
TIM1_SetCounter(1);
TIM1->PSCRH = 0;
TIM1->PSCRL = 15;
TIM1->EGR =TIM1_PSCRELOADMODE_IMMEDIATE;
}