在官网下载了最新的库文件,在 stm8l15x_tim4.c文件中看到如下描述: =================================================================== TIM4 Driver: how to use it in Timing(Time base) Mode =================================================================== To use the Timer in Timing(Time base) mode, the following steps are mandatory: 1. Enable TIM4 clock using CLK_PeripheralClockConfig(CLK_Peripheral_TIM4, ENABLE) function. 2. Call TIM4_TimeBaseInit() to configure the Time Base unit with the corresponding configuration. 3. Enable global interrupts if you need to generate the update interrupt. 4. Enable the corresponding interrupt using the function TIM4_ITConfig(TIM4_IT_Update) 5. Call the TIM4_Cmd(ENABLE) function to enable the TIM4 counter. 因此,我写了一个定时的timer: main.c函数: Clk_AutoSwitch(CLK_SYSCLKSource_LSI); CLK_RTCCLKSwitchOnLSEFailureEnable(); CLK_LSEClockSecuritySystemEnable(); /* Enable TIM4 CLK */ CLK_PeripheralClockConfig(CLK_Peripheral_TIM4, ENABLE); /* TIM4 configuration: - TIM4CLK is set to 32 K Hz, the TIM4 Prescaler is equal to 128 so the TIM1 counter clock used is 32 KHz / 128 = 250 Hz - With 250 Hz we can generate time base: max time base is 1.024 s if TIM4_PERIOD = 255 --> (255 + 1) / 250 = 1.024s min time base is 8 ms if TIM4_PERIOD = 1 --> ( 1 + 1) / 125000 = 8 ms - In this examle we need to generate a time base equal to 1 ms so TIM4_PERIOD = (0.001 * 125000 - 1) = 124 */ /* Time base configuration */ TIM4_TimeBaseInit(TIM4_Prescaler_128, 250); //调整参数,可以改变定时时间? /* enable interrupts */ enableInterrupts(); /* Enable update interrupt */ TIM4_ITConfig(TIM4_IT_Update, ENABLE); /* Clear TIM4 update flag */ TIM4_ClearFlag(TIM4_FLAG_Update); /* Enable TIM4 */ TIM4_Cmd(ENABLE); 中断函数: INTERRUPT_HANDLER(TIM4_UPD_OVF_TRG_IRQHandler, 25) { /* In order to detect unexpected events during development, it is recommended to set a breakpoint on the following instruction. */ GPIO_ToggleBits(LED_BL_PORT,LED_BL_PIN); TIM4_ClearITPendingBit(TIM4_IT_Update); } 结果,中断可以进入,但是中断时间不可以调整。 按照我的理解, TIM4_TimeBaseInit(TIM4_Prescaler_128, 250);调整参数会改变触发中断的时间,结果没有任何作用。 实际我的需求是,调整定时时间。这个定时Base怎么理解? 请帮帮指点. |
从零开始操作STM8寄存器(风驰iCreate奉献)
【中文资料】初学STM8库函数的中文帮助软件
绝对经典的中文STM8学习手册,淘宝上学习板资料,友情大放送!
【原创教程】风驰iCreate独家开源STM8 27个例程和10多万字的pdf教程
STM8的LCD1602 4线驱动,为什么不工作
【精华资料】由零开始开发STM8
STM8S 的触摸库是如何在主程序中查询键的呢、
【精华资料】STM8的C语言编程1-14讲完整版
【精品教程】STM8系列单片机入门教程系列
STM8 第一次进中断不准【悬赏问答】
RE:STM8L TIMER4 定时中断时间不能调整
RE:STM8L TIMER4 定时中断时间不能调整
上述代码没有问题。