While I have yet to implement this on the LPC ARMs the following
is an approach I have been using with success for years.
At system startup setup a timer counter to increment at a rate
that will cause it to rollover at a convenient period (1-15 mSec).
Also initialize a 32 bit variable 'sysTICs' to 0.
In the rollover interrupt routine, increment sysTICs.
For delays of the rollover interval use routines like:
uint32_t getSysTICs(void)
return sysTICs;
uint32_t getElapsedTICs(uint32_t startTICs)
return (sysTICs - startTICs);
void pause(uint32_t pauseTICs)
uint32_t startTime = getSysTICs();
while (getElapsedTICs(startTICs) < pauseTICs)
/* do something else */ ;
For short delays, you can replace sysTICs with the current value
of the Timer Counter Register.
uint32_t delay(uint32_t delay)
uint32_t start = TC;
while ((TC - start) < delay)
/* do almost nothing else */ ;
Hope this helps.
-Bill Knight
R O SoftWareMessage
Re: [lpc2100] Re: Delay routines
2003-12-05 by Bill Knight
Attachments
- No local attachments were found for this message.