Fex timer sample code

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Fex timer sample code

1,117 Views
punithb
Contributor I

HI All,

I am using SKEAZN64MLC controller in my project,

Now i need to implement some timer logic for my requirement.

I need to keep on count the timer count value, once counter value greater than some predefined value , then i need to stop timer.

and again start the timer by count value initializing to 0.

1. How to start and stop flex timer?.

2. How to initialize the timer to count for 1 us.?.

void FTM_Init()

{

      SIM->SCGC |= SIM_SCGC_FTM2_MASK; /* Enable Clock for FTM2 */

     FTM2->SC |= FTM_SC_PS(3);

       FTM2->SC |= FTM_SC_CLKS(3); /*FTM2 use system clock*/

// external clock is 8MHZ so 8/2^3=1mhz so timer increment for each 1 us.

}

is this correct?.

3. is timer count will automatically update to FTM2->CNT or need to capture every time?.

Basically i need to set of sample codes for flex timers , kindly share to me.

0 Kudos
Reply
4 Replies

875 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello ,

Which IDE do you use ?

If you use KDS, i recommend you create one PE project , then add the "Init_FTM" component or "TimerOut_LDD" component ,

then generate code ,  you can find the configuration about the FTM.

pastedImage_0.png

Hope it helps

Alice

0 Kudos
Reply

875 Views
punithb
Contributor I

Hi Alice,


Thanks for your reply. 

Yes i am using KDS.

I created on PE Project and now i called the function spi_init() in main, now how to generate code for this?.

Regards

Punith

0 Kudos
Reply

875 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello ,

Call the function spi_init() ???

If you want use the flex timer , please add the component of "Init_FTM" or "TimerOut_LDD",

then configure it , then click generate code button here :

pastedImage_1.png

then you can fund the generated code here :

pastedImage_0.png

pastedImage_2.png

If still have any question, please send your project to me . I use KDS3.0 .

Hope it helps

Alice

0 Kudos
Reply

875 Views
punithb
Contributor I
0 Kudos
Reply