Problem with 2 Match Interrupts

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

Problem with 2 Match Interrupts

456 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Patrick_W on Wed Jul 08 06:40:39 MST 2015
Hey Guys,

after a long time its me again. I got a problem using two match interrupts on timer 2.
When the ISR is called both match interrupt flags are set (even if the TC value is far below the Match Register Value)

This is the code of my init function:


Chip_Clock_SetPCLKDiv(SYSCTL_PCLK_TIMER2, SYSCTL_CLKDIV_1);
Chip_TIMER_Init(LPC_TIMER2);

Chip_TIMER_Reset(LPC_TIMER2);

Chip_TIMER_PrescaleSet(LPC_TIMER2, 0);

Chip_TIMER_SetMatch(LPC_TIMER2, 1, 1600);
Chip_TIMER_SetMatch(LPC_TIMER2, 2, 9200000);//zu Testzwecken

Chip_TIMER_ClearMatch(LPC_TIMER2, 1);
Chip_TIMER_ClearMatch(LPC_TIMER2, 2);

Chip_TIMER_ResetOnMatchEnable(LPC_TIMER2, 2);
Chip_TIMER_MatchEnableInt(LPC_TIMER2, 1);
Chip_TIMER_MatchEnableInt(LPC_TIMER2, 2);

NVIC_ClearPendingIRQ(TIMER2_IRQn);
NVIC_EnableIRQ(TIMER2_IRQn);



And the code of the ISR:

void TIMER2_IRQHandler(void)
{
if(Chip_TIMER_MatchPending(LPC_TIMER2, 1))
{
UpdatePulsDACValue = true;
Chip_TIMER_ClearMatch(LPC_TIMER2, 1);
}

if(Chip_TIMER_MatchPending(LPC_TIMER2, 2))
{
UpdatePulsDACValue = false;
Chip_TIMER_ClearMatch(LPC_TIMER2, 2);
}

NVIC_ClearPendingIRQ(TIMER2_IRQn);
}


If i check the register configuration during debugging the MCR, and MR look correct.
Just to mention it: the timer is enabled via an extra function.

I am working on a LPC1763 with a 16MHz crystal no PLL.
For programming i use the LPC Link2, SW: LPCXpresso v7.6.2 on Win7

Has somebody a advice what i am doing wrong?

Best regards




标签 (1)
0 项奖励
回复
2 回复数

437 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Patrick_W on Wed Jul 08 23:06:50 MST 2015
You're right, stupid mistake :-D

But thanks for the answer.
0 项奖励
回复

437 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Wed Jul 08 08:38:57 MST 2015

Quote: Patrick_W
Has somebody a advice what i am doing wrong?



You are posting code snippets...

Probably the timer is confusing you  :)  The timer isn't stopped, so it's generating interrupts while you are staring at the breakpoint  :O


0 项奖励
回复