LPIT0 Ch1 Interrupt.

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

LPIT0 Ch1 Interrupt.

跳至解决方案
2,145 次查看
antonio_rodrigu
Contributor II

Hello,

I need to configure LPIT0_CH1 in S32K144-QN57U, after some attempts I was not able to make it work, can anyone help me to review next configuration :

Thank you, Antonio.

#define LPIT0_BASE (0x40037000u)

#define LPIT0 ((LPIT_Type *)LPIT0_BASE)

void NVIC_init_IRQs (void) {
S32_NVIC->ICPR[1] = 1 << (49 % 32);
S32_NVIC->ISER[1] = 1 << (49 % 32);
S32_NVIC->IP[49] = 0xF0;
}

void LPIT0_init (void) {
PCC->PCCn[PCC_LPIT_INDEX] = PCC_PCCn_PCS(6);
PCC->PCCn[PCC_LPIT_INDEX] |= PCC_PCCn_CGC_MASK;
LPIT0->MCR = 0x00000001;
LPIT0->MIER = 0x00000010;
LPIT0->TMR[1].TVAL = 10000000;
LPIT0->TMR[1].TCTRL = 0x10000001;
}


void LPIT0_Ch1_IRQHandler (void) {
LPIT0->MSR |= LPIT_MSR_TIF1_MASK; /* Clear LPIT1 timer flag 0 */

PTD->PTOR |= 1<<LED_GREEN; /* Toggle output on port */
}

标签 (1)
标记 (4)
1 解答
1,865 次查看
stanish
NXP Employee
NXP Employee

Hi Antonio,

From the code snippet it seems the problem seems to be caused by wrong PIT interrupt enable register (MIER):

pastedImage_1.png

void LPIT0_init (void) {
PCC->PCCn[PCC_LPIT_INDEX] = PCC_PCCn_PCS(6); 
PCC->PCCn[PCC_LPIT_INDEX] |= PCC_PCCn_CGC_MASK; 
LPIT0->MCR = 0x00000001; 
LPIT0->MIER = 0x00000002;    // channel 1 enable (TIE1)
LPIT0->TMR[1].TVAL = 10000000; 
LPIT0->TMR[1].TCTRL = 0x10000001; 
}


Hope it helps,

Stan

在原帖中查看解决方案

2 回复数
1,866 次查看
stanish
NXP Employee
NXP Employee

Hi Antonio,

From the code snippet it seems the problem seems to be caused by wrong PIT interrupt enable register (MIER):

pastedImage_1.png

void LPIT0_init (void) {
PCC->PCCn[PCC_LPIT_INDEX] = PCC_PCCn_PCS(6); 
PCC->PCCn[PCC_LPIT_INDEX] |= PCC_PCCn_CGC_MASK; 
LPIT0->MCR = 0x00000001; 
LPIT0->MIER = 0x00000002;    // channel 1 enable (TIE1)
LPIT0->TMR[1].TVAL = 10000000; 
LPIT0->TMR[1].TCTRL = 0x10000001; 
}


Hope it helps,

Stan

1,865 次查看
antonio_rodrigu
Contributor II

Yes, It worked.

Thank you, Stanislav... cheers with vodka!

0 项奖励
回复