Kinetis K66F - Periodic Interrupt Timer (PIT) is missing interrupt handlers

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

Kinetis K66F - Periodic Interrupt Timer (PIT) is missing interrupt handlers

1,325 Views
x_vehicle
Contributor I

Hello everyone,

I need a little bit of help regarding my project, which should utilize Periodic Interrupt Timer (PIT).

I am trying to build 6-pulse IGBT inverter to power a three phase motor, and to control the IGBTs I need fast MCU. Search has filtered out FRDM-K66F with 180 MHz clock as possible solution.

Now I am investigating if this MCU can perform needed tasks. Algorithm for controlling six IGBTS basically consists of generating ON and OFF impulses which are routed to gate inputs of IGBTs. Generation of impulses relies on keeping precise time, and interrupts timers which have to generate ON and OFF commands. For this to happen, Periodic Interrupt Timer (PIT) could be useful.

On previous MCUs, interrupt timers work like this: you setup the timer to raise an interrupt after XY nanoseconds(yes nanoseconds)/microseconds and afterwards continue doing whatever you like to do on a MCU (let's say you want your controller to calculate first million prime numbers :) – I couldn't thing anything better than that, but it will serve for showing my point). During the calculation of prime numbers, an interrupt occurs, and CPU immediately stops calculating prime numbers and starts executing interrupt handler procedure, which in my case could be: turn ON output 15 and 16 and turn OFF output 17, and finally set new time delay value for interrupt timer, and return to calculating prime numbers. The process repeats itself indefinitely.

Now, my problem is I can't find in Kinetis SDK 2.0 API Reference Manual, found here:

https://mcuxpresso.nxp.com/apidoc/group__pit__driver.html

... a PIT initialization function which could take for parameter my interrupt handler procedure. I can set flags, I can read flags when interrupt occurs, but I can not find a way to force CPU to stop calculating prime numbers and start executing something else by itself.

I do not wish to check if some bit in some register has switched value from 0 to 1, just to know that the "interrupt" has happened. I want it to happen automatically. Right now PIT looks to me as if it is behaving as normal timer, without, INTERRUPT ability.

Am I doing something wrong?

I found a tutorial:

https://www.nxp.com/docs/en/supporting-information/Periodic-Interrupt-Timer-Training.pdf

...which on page 8 also manually checks for flags, but this kind of behavior is missing INTERRUPT part of PITs.

0 Kudos
2 Replies

859 Views
mjbcswitzerland
Specialist V

Hi Pero

The PIT in the K66 has 4 channels which each have their own interrupt and DMA capability (and can trigger some other modules, such as ADCs). The PIT however has no output pin of its own.

For your application you may find the FlexTimer/TPM in the K66 to be more suitable since it has more DMA and interrupt capabilities and it has its own physical outputs that can be controlled directly from HW, rather than using interrupts (with their associated jitter). Their DMA capabilities also allows control of various algorithms (such as stepper motor ramping) with no SW (interrupt) overhead.

For professional requirements also take a look at the uTasker project (its HW Timer document, showing the interface which works on all Kinetis parts with FlexTimer, TPM, PIT and LPITs and thus ensures compatibility across all parts is at http://www.utasker.com/docs/uTasker/uTaskerHWTimers.PDF). It shows PIT singe shot interrupt and periodic interrupt use.

I have attached the PIT module code (supporting compatible operation on PITs with shared interrupts and independent channel interrupts, and LPITs) as reference. All HW timers can be simulated in the project in Visual Studio to improve development, testing and debugging efficiency.

Regards

Mark

Complete K66 solutions, training and support: http://www.utasker.com/kinetis/FRDM-K66F.html

0 Kudos

859 Views
x_vehicle
Contributor I

Tnx Mark for the answer, I'll investigate uTasker solutions.

0 Kudos