关于STM8L的TIM1初始化问题,请教一下,
初始化代码如下:
void TIM1_init0(void)
{
CLK->PCKENR2 |=CLK_PCKENR2_TIM1;
TIM1->CR1 = 0;
TIM1->PSCRH = 0x3E;
TIM1->PSCRL = 0x80; // 1000Hz = 1mS 计数频率(定时器时钟) Fcn = f /(PSCR+1) f :系统时钟 16M
TIM1->CNTRH = 0;
TIM1->CNTRL = 0;
TIM1->ARRH = 0x00;
TIM1->ARRL = 0x32; //
TIM1->IER = 0x01;
//TIM1->EGR = 0x01;
TIM1->CR1 = 0x01;
//TIM1->RCR = 56;
}
中断函数如下:
INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_COM_IRQHandler, 23)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
static unsigned int nomlnum = 0;
TIM1->SR1 =0;
nomlnum++;
if(!(nomlnum%10)) GPIOC->ODR ^=GPIO_Pin_1;
}
仿真的时候,感觉没进中断,没达到预设的结果,麻烦帮看看问题出在哪里,谢谢了 |