KE16Z Pit Timer works only for one second

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

KE16Z Pit Timer works only for one second

跳至解决方案
532 次查看
attiliorossi321
Contributor II

Hi guys

I post my code about pit timer on KE16Z. It work fine and properly but only for just one second about.

Later I can't reach the interrupt handle again. 

Any suggestion for me ?

Thanks in advance

Attilio

 

 

void PIT_Init(void)
{
       uint32_t reg = 0;

       PCC->CLKCFG[PCC_LPIT0_INDEX] |= PCC_CLKCFG_CGC_MASK;
       LPIT0->MCR |= LPIT_MCR_SW_RST_MASK;
       LPIT0->MCR &= ~LPIT_MCR_SW_RST_MASK;

       LPIT0->MCR = LPIT_MCR_DBG_EN(0) |
                                 LPIT_MCR_DOZE_EN(0) |
                               LPIT_MCR_M_CEN_MASK;

        LPIT0->MIER |= LPIT_MIER_TIE0_MASK;

      reg =  LPIT_TCTRL_MODE(0) |

                LPIT_TCTRL_TRG_SRC(1) |

                LPIT_TCTRL_TRG_SEL(0) |             

                 LPIT_TCTRL_TROT(1) |

                LPIT_TCTRL_T_EN_MASK;
   

        LPIT0->CHANNEL[0].TCTRL = reg;


        LPIT0->SETTEN |= LPIT_SETTEN_SET_T_EN_0_MASK;


       LPIT0->CHANNEL[0].TVAL = 24000;

}

 


void LPIT0_Interrupt(void)
{
   static bool b;

   LPIT0->MSR |= LPIT_MSR_TIF0_MASK;

   b = (b == false) ? true : false;
   (b == true) ? Set_TestPin() : Res_TestPin();
}

0 项奖励
回复
1 解答
528 次查看
nxf58904
NXP Employee
NXP Employee

Hi,

I checked your code , you didn't enable an interrupt.

Add this "NVIC_EnableIRQ(LPIT0_IRQ);"  to the PIT_Init() function.

Have a try .

 

Jianyu: 

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

在原帖中查看解决方案

0 项奖励
回复
1 回复
529 次查看
nxf58904
NXP Employee
NXP Employee

Hi,

I checked your code , you didn't enable an interrupt.

Add this "NVIC_EnableIRQ(LPIT0_IRQ);"  to the PIT_Init() function.

Have a try .

 

Jianyu: 

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 项奖励
回复