PIT Interrupt

cancel
Showing results for 
Search instead for 
Did you mean: 

PIT Interrupt

403 Views
maratheapurv
Contributor III

I'm trying to write a program for the PIT module of the FRDM-KV31F board using MCUXPRESSO but the code gets stalled in the while loop.

Is this happening because I haven't provided an interrupt routine? What changes should I perform?

Thank you,

Apurv Marathe.

Labels (1)
2 Replies

201 Views
mjbcswitzerland
Specialist V

Hi

Your code doesn't use interrupts, it just polls the timeout flag

    while(!(PIT->CHANNEL[1].TFLG & PIT_TFLG_TIF_MASK))
    {
         PTD->PSOR |= 0x2;
    }
         PTD->PCOR |= 0x2;
    return 0 ;

It would also quit after the first period.

PTD->PSOR |= 0x2; should really be PTD->PSOR = 0x2;
and PTD->PCOR |= 0x2; PTD->PCOR = 0x2; although it will work as you have it.

To make it run forever you could do:

while (1 != 0) {

    PTD->PSOR = 0x2;

    while(!(PIT->CHANNEL[1].TFLG & PIT_TFLG_TIF_MASK)) {}

    PTD->PCOR = 0x2;

    PIT->CHANNEL[1].TFLG = PIT_TFLG_TIF_MASK; // clear flag

    while(!(PIT->CHANNEL[1].TFLG & PIT_TFLG_TIF_MASK)) {}

    PIT->CHANNEL[1].TFLG = PIT_TFLG_TIF_MASK; // clear flag

}
(or similar).

I think your main issue that stops it working is your line

PIT->MCR |= 0x0;  //activate pit module

MCR has the value 0x00000002 (disabled) out of reset and to start it one does

PIT->MCR = 0x0; (and not PIT->MCR |= 0x0; since this has no effect)

Regards

Mark

Complete Kinetis solutions for professional needs, training and support: http://www.utasker.com/kinetis.html
Kinetis KV31:
- http://www.utasker.com/kinetis/FRDM-KV31F.html


uTasker: supporting >1'000 registered Kinetis users get products faster and cheaper to market
Request Free emergency remote desk-top consulting at http://www.utasker.com/services.html

Open Source version at https://github.com/uTasker/uTasker-Kinetis

201 Views
maratheapurv
Contributor III

Hello Mark,

Thank you so much for your help!! That was such a silly mistake.

Thank you once again,

Apurv.

0 Kudos