Hello,
I was trying to generate timer interrupt on TPM2 of KL15 processor.
I used following function in setting up the timer interrupt.
void Tpm2Init(void)
{
//! Status and Control Register (TPM2_SC)
//! - Clear status and control register
TPM2_SC = (uint32_t)0x00000000;
//! Modulo Register (TPM2_MOD)
// TODO: Update these values based on power modes
//! - Period value is 10 milli seconds / (1/6MHz) = 60000
TPM2_MOD = (uint32_t)0x0000EA60;
//! Channel Status and Control Register (TPM2_C0SC)
//! - Enable channel interrupt [CHIE = 1]
//! - TPM Channel disabled [MSB = 0, MSA = 1, ELSB = 0, ELSA =0]
TPM2_C0SC = (uint32_t)0x00000050;
//! Channel Value (TPM2_C0V)
// TODO: Update these values based on power modes
//! - Period value is 1 milli second / (1/6MHz) = 6000
TPM2_C0V = (uint32_t)0x00001770;
//! Status and Control Register (TPM2_SC)
//! - Timer Overflow Interrupt Enable [TOIE = 0]
//! - LPTPM counter operates in up counting mode [CPWMS = 0]
//! - LPTPM counter increments on every LPTPM counter clock [CMOD = 1]
//! - Prescaler Factor Selection is divide by 4 [PS = 2]
TPM2_SC = (uint32_t)0x0000000A;
}
I checked and found out that timer interrupt is triggered for every 10 milli seconds with the above mentioned code (at TPM2_MOD value) and not at TPM2_C0V value.
I would like to know whether TPM2_C0V will be used in “Software Compare” mode.
In “SIM_SOPT2” register MCGFLLCLK is selected as TPM clock source and I have configured MCGFLLCLK as 24 MHz.
Could anyone help me on this?
Thanks in advance,
Regards,
Anand