今天使用F415定时器TMR2,发现CLKDIV无论配置为多少,计数频率都不变。如下代码,不知是不是我理解错了CLKDIV的含义
void peripheral_time_base_init(void)
{
tmr_32_bit_function_enable(TMR2, TRUE); //开启32位
tmr_base_init(TMR2, 0xFFFFFFFF, 36000 - 1); //TMR2时钟为36MHz,1ms计数一次
tmr_cnt_dir_set(TMR2, TMR_COUNT_UP); //向上计数
tmr_clock_source_div_set(TMR2, TMR_CLOCK_DIV1); //不管是TMR_CLOCK_DIV1,还是TMR_CLOCK_DIV4,实测定时器都是1ms计数一次
tmr_counter_enable(TMR2, TRUE); //开始计数
}
附时钟树配置,使用官方工具生成:
/**
* @brief system clock config program
* @NOTE the system clock is configured as follow:
* system clock (sclk) = hext * pll_mult
* system clock source = pll (hext)
* - hext = 8000000
* - sclk = 144000000
* - ahbdiv = 1
* - ahbclk = 144000000
* - apb1div = 8
* - apb1clk = 18000000
* - apb2div = 2
* - apb2clk = 72000000
* - pll_mult = 18
* - flash_wtcyc = 4 cycle
* @param none
* @retval none
*/
|