Hello, first time user here. I kind of understand what I have to do, however i have a hard time executing code. I've been reading the manual, but it doesn't help me too much. I learn more with examples, and it shows none. My question is, how can I create a 5 kHz interrupt using PIT? The part that I am stuck right now at is loading the LDVAL register, I cannot find a clock that I can use, I only have CPU_INT_IRC_CLK_HZ, but it runs at 48 MHz, a little too high. Can someone show me an example of how to enable and what include files I need? I'd greatly appreciate it, thank you.
Hi Matias:
Please refer to the pit demo in SDK. The PIT project is a simple demonstration program of the SDK PIT driver.
SDK_2.3.0_FRDM-K66F\boards\frdmk66f\driver_examples\pit
Regards
Daniel
Hi Matias
The PIT uses always the bus clock.
For 5kHz interrupt in the uTasker project:
PIT_SETUP pit_setup; // PIT interrupt configuration parameters
pit_setup.int_type = PIT_INTERRUPT;
pit_setup.int_priority = PIT0_INTERRUPT_PRIORITY;
pit_setup.int_handler = irq_pit; // irq call-back
pit_setup.count_delay = PIT_FREERUN_FREQ(5000); // 5kHz
pit_setup.mode = (PIT_PERIODIC); // periodic trigger
pit_setup.ucPIT = 0; // use PIT0
fnConfigureInterrupt((void *)&pit_setup); // configure and start PIT
static void irq_pit(void)
{
// toggle LED
}
Use the links below for complete code (runs on all Kinetis parts) and Kinetis simulation so that you can analyse the code and internal working of the PIT (and other peripherals), including its interrupt and DMA capabilities.
Regards
Mark
Kinetis: http://www.utasker.com/kinetis.html
Kinetis K64:
- http://www.utasker.com/kinetis/FRDM-K64F.html
- http://www.utasker.com/kinetis/TWR-K64F120M.html
- http://www.utasker.com/kinetis/TEENSY_3.5.html
- http://www.utasker.com/kinetis/Hexiwear-K64F.html
HW Timers: http://www.utasker.com/docs/uTasker/uTaskerHWTimers.PDF
Free Open Source solution: https://github.com/uTasker/uTasker-Kinetis
Working project in 15 minutes video: https://youtu.be/K8ScSgpgQ6M
For better, faster, cheaper product developments consider the uTasker developer's version, professional Kinetis support, one-on-one training and complete fast-track project solutions to set you apart from the herd : http://www.utasker.com/support.html
That helps quite a bit. Thank you!