11 years, 1 month ago.  This question has been closed. Reason: Duplicate

Can anyone tell me why I don't seem to be getting any PIT interrupts?

<< FRDM KL25Z >> << Sorry, not sure why the code doesn't show up correctly. Use edit to read >>

  1. include "mbed.h"

extern void PIT_IRQHandler();

unsigned char Iflag;

DigitalOut myled(LED1); blue DigitalOut intled(LED2); green

void baud(int baudrate) { Serial s(USBTX, USBRX); s.baud(baudrate); }

void pit_init(void) PIT Initialization { SIM->SCGC6 |= SIM_SCGC6_PIT_MASK; Enable the clock to the PIT module

NVIC_SetVector(PIT_IRQn, (uint32_t)PIT_IRQHandler);

NVIC_EnableIRQ(PIT_IRQn); Initialize the NVIC to enable the PIT interrupt

PIT->MCR = 0X00; turn on the PIT

PIT->CHANNEL[0].TFLG = PIT_TFLG_TIF_MASK; Reset the Timeout Flag

PIT->CHANNEL[0].LDVAL = 80000000; Default start value 1.6 sec.

PIT->CHANNEL[0].TCTRL = PIT_TCTRL_TIE_MASK; Enable timer PIT->CHANNEL[0].TCTRL |= PIT_TCTRL_TEN_MASK; Enable timer interrupt

Iflag = 0; }

void PIT_IRQHandler() { PIT->CHANNEL[0].TCTRL = 0; Disable timer PIT->CHANNEL[0].TFLG = PIT_TFLG_TIF_MASK; Clear the timer interrupt flag PIT->CHANNEL[0].TCTRL |= PIT_TCTRL_TEN_MASK | PIT_TCTRL_TIE_MASK; Enable timer

Iflag = 1; }

int main() {

myled = 1; blue intled = 1; green

baud(57600); printf("Starting PIT test\n\r");

pit_init();

while(1) { if (Iflag == 1) { Iflag = 0; myled = 1; turn off blue led intled = 0; flash green led printf("PIT\n\r"); wait(0.9); intled = 1; }

myled = !myled; toggle blue led wait(0.9); } }