版主大佬,请教一个LPTMR的问题,LPTMR的时钟源如果选为LPO 1KHz,能分频吗?
void LPTMR_init(uint8 workmode)
{
SIM_SCGC5 |= SIM_SCGC5_LPTMR_MASK;
/* Ensure Internal Reference Clock is Enabled */
MCG_C1 |= MCG_C1_IRCLKEN_MASK;
//Enable fast internal ref clock by setting MCG_C2[IRCS]=1
//If wanted to use 32Khz slow mode, set MCG_C2[IRCS]=0 instead
MCG_C2 |= MCG_C2_IRCS_MASK;
// Clear LPTMR register
LPTMR0_CSR=0x00;
LPTMR0_PSR=0x00;
LPTMR0_CMR=0x00;
enable_irq(LPTMR_irq_no);
if (workmode==VLLS3MODE)
{
LPTMR0_PSR = ( LPTMR_PSR_PBYP_MASK | LPTMR_PSR_PCS(1) ) ; // use the 01 LPO 1 kHz clock in VLLS3 mode
//LPTMR0_CMR = LPTMR_CMR_COMPARE(60000); //Set compare value about 1 minute
LPTMR0_CMR = LPTMR_CMR_COMPARE(600);
}
else if (workmode==VLLS3VBUS)
{
LPTMR0_PSR = ( LPTMR_PSR_PBYP_MASK | LPTMR_PSR_PCS(1) ) ; // use the 01 LPO 1 kHz clock in VLLS3 mode
LPTMR0_CMR = LPTMR_CMR_COMPARE(60000); //Set compare value about 1 minute
}
else
{
LPTMR0_PSR = ( LPTMR_PSR_PBYP_MASK | LPTMR_PSR_PCS(0)) ; // use the 00 MCGIRCLK in normal mode // LPO feeds directly to LPT
LPTMR0_CMR = LPTMR_CMR_COMPARE(10300); //Set compare value about 5ms
}
LPTMR0_CSR=LPTMR_CSR_TIE_MASK; //Enable LPT interrupt
LPTMR0_CSR |= LPTMR_CSR_TEN_MASK; //Turn on LPT and start counting
}
这段是我的LPTMR初始化函数,但是发现分频后中断的时间间隔在修改模式的时候还是没有变化,请指导!!!
|