PIT Interrupt

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

PIT Interrupt

1,664 次查看
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.

标签 (1)
标记 (2)
2 回复数

1,462 次查看
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

1,462 次查看
maratheapurv
Contributor III

Hello Mark,

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

Thank you once again,

Apurv.

0 项奖励
回复