Is SysTick COUNTFLAG required to be cleared ?

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

Is SysTick COUNTFLAG required to be cleared ?

3,060 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by noritan_org on Fri Jan 29 23:17:25 MST 2010
In the example project "systick" for the LPCXpresso LPC1114, there is an exception handler as follows.
void SysTick_Handler(void) {
  msTicks++;                        /* increment counter necessary in Delay() */
}
I wonder why this handler has no code to clear the COUNTFLAG of the SYST_CSR register.

It was described in the page 307 on 00.10 version of user manal UM10398, the COUNTFLAG register can be cleared by reading the SYST_CSR register.   I understand that the exception will be activated during the COUNTFLAG is 1, and the SysTick exception handler is continued to be executed until the COUNTFLAG is cleared.  But, the results attempting the project "systick" is different from my assumption.  The SysTick exception is invoked periodically.

My questions are :
1. Is the COUNTFLAG automatically cleared when a SysTick exception is activated ?
2. Is there an another internal (invisible) pending flag causing SysTick exception separated from the COUNTFLAG ?
3. Is it required to read the SYST_CSR register in the SysTick handler to clear the COUNTFLAG ?

Thanks in advance.
0 项奖励
回复
2 回复数

2,789 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by noritan_org on Mon Feb 01 07:26:54 MST 2010
Thank you for clear answers.
I wouldn't worry about the COUNTFLAG in the exception handler.
0 项奖励
回复

2,789 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by NXP_USA on Sat Jan 30 17:12:25 MST 2010

Quote: noritan_org
In the example project "systick" for the LPCXpresso LPC1114, there is an exception handler as follows.
...

I wonder why this handler has no code to clear the COUNTFLAG of the SYST_CSR register.

My questions are :
1. Is the COUNTFLAG automatically cleared when a SysTick exception is activated ?
2. Is there an another internal (invisible) pending flag causing SysTick exception separated from the COUNTFLAG ?
3. Is it required to read the SYST_CSR register in the SysTick handler to clear the COUNTFLAG ?

Thanks in advance.



1. The COUNTFLAG is set when the SysTick counter decrements from 1 to 0 and is not cleared by the interrupt.
2. The SysTick interrupt is controlled by ICSR->PENDSTSET and ICSR->PENDSTCLR. PENDSTSET can be read to determine if a SysTick exception is pending. It would only show as pending if the SysTick interrupt was blocked by a higher priority interrupt, otherwise it would be serviced and cleared in hardware. It does not need to be cleared by the interrupt.
3. The COUNTFLAG does not trigger the SysTick interrupt.

Regards,
-NXP
0 项奖励
回复