AnsweredAssumed Answered

S9KEAZN8 minimum PIT or FTM period

Question asked by Ralf Van Den Boogaart Employee on Sep 20, 2018
Latest reply on Sep 21, 2018 by Ralf Van Den Boogaart

Hello,

 

Currently I'm working with an S9KEAZN8AMTG micro and I'm trying to achieve a very high timer interrupt frequency.

My goal is to have a FTM timer which I can use to generate sub-microsecond interrupts because I need an accurate way to execute actions on t=4 microseconds and t=10 microseconds. Until so far I have not been able to set the interrupt rate faster than ~1 microsecond.

 

I have set the 32kHz IRC to supply the FLL with a clock, and this clock is then passed to the FTM module without any clock prescaling active. As far as I can see this should give the FTM module a clock of ~48MHz. I assume that when I set the modulo value to 24, I should have an interrupt every 0.5 microseconds.

 

void clock_init (void) { /* FLL Enabled with Internal clock */
OSC_CR = 0x00; /* (default value) */
                           /* OSCEN=0: OSC module disabled */
                           /* OSCSTEN=0: OSC clock disabled in Stop mode */
                           /* OSCOS=0: Ext clk source (don't care here) */
                           /* RANGE=0: Low Freq range of 32 KHz */
                           /* HGO=0: low power High Gan Osc mode (don't care here) */
ICS_C2 = 0x20; /* Use defaults until dividers configured (default) */
                           /* BDIV=1: divided by 2 */
                           /* LP = 0: FLL Not disabled in bypass mode */
ICS_C1 = 0x04; /* Internal ref clock is FLL source (default)*/
                           /* CLKS=0: Output of FLL is selected to control bus freq */
                           /* RDIV=0: Ref divider = 1 since RANGE = 0 */
                           /* IREFS=0: Int Ref clock is selected */
                           /* IRCLKEN=0: ICSIRCLK is inactive */
                           /* IREFSTEN=0: Int ref clk is disabled in Stop mode */
while ((ICS_S & ICS_S_LOCK_MASK) == 0); /* Wait for FLL to lock*/
SIM_CLKDIV = 0x01000000; /* OUTDIV1 = 0; Core/sysclk is ICSOUTCLK div by 1 */
                                                /* OUTDIV2 = 1 bus/flash is OUTDIV1/2 */
                                                /* OUTDIV3 = 1; FTMs, PWT is ICSOUTCLK div by 2 */
ICS_C2 = 0x00;    /* BDIV div 1:1 - increases bus/flash freq */
}

 

void init_FTM(void) {

 

ftm0_nvic_irq_init();
SIM_SCGC |= SIM_SCGC_FTM0_MASK; /* Sys Clk Gate Ctrl: enable bus clock to FTM0 */


FTM0_SC = 0x00000048; /* FTM0 module settings for desired channel modes: */
                                          /* CWMS (Center aligned PWM Select) = 0 (default, up count) */
                                          /* TOIE (Timer Overflow Interrupt Ena) = 0 (default) */
                                          /* CLKS (Clock source) = 0 (default, no clock; FTM disabled) */
                                          /* PS (Prescaler factor) = 0 (default). Prescaler = 2**0 = 1 */
FTM0_MOD = 24; /* FTM0 counter final value */
                              /* FTM0 Period = MOD-CNTIN+0x0001 ~= 24 ctr clks */
                              /* 24 clks x 1 sec/48M clks = 0.5us (2MHz) */
}

 

Is it possible to get the FTM timer faster than an interrupt every ~1 microsecond, something like 0.2 microseconds, or is this not possible?

 

Thank you,

Ralf

Outcomes