Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Thread

Delay Funtion Ready -- My first contribution to the Group

Delay Funtion Ready -- My first contribution to the Group

2004-12-27 by acetoel

Hello to everybody... Here is ready and tested, my Delay Function
using Timer 0 with 1uSec resolution. Please, cheack it, test it, and
send critrics about it... 
Bye bye
Kimi

//---------------- delayus.h  file ---------------------------
/* Developed by: Ezequiel Leonardo Aceto
   Date: 27/12/2004
   E-mail: sunixs@...
*/   
  
/* Delay function - Works with 60Mhz CCLK and 60MHZ PCLK
Modify the TIMER0_PR value using this Rule
TIMER0_PR = (PCLK/1000)-1 to obtain a 1uS resolution
Enjoy it...and post comments */

// Delayus.H 


#define TIMER0_TCR     (*((volatile unsigned long *) 0xE0004004))
#define TIMER0_TC      (*((volatile unsigned long *) 0xE0004008))
#define TIMER0_PR      (*((volatile unsigned long *) 0xE000400C))

#ifndef DELAYUS_H
#define DELAYUS_H
void delayus (unsigned long usdelay );
#endif
//----------- End of delayus.h File ------------------------

//--------------- delayus.c file --------------------------
/* Developed by: Ezequiel Leonardo Aceto
   Date: 27/12/2004
   E-mail: sunixs@...
*/   
  
/* Delay function - Works with 60Mhz CCLK and 60MHZ PCLK
Modify the TIMER0_PR value using this Rule
TIMER0_PR = (PCLK/1000)-1 to obtain a 1uS resolution
Enjoy it...and post comments */

// Delayus.C

void delayus (unsigned long usdelay ) {
	 TIMER0_PR  = 0xEA5F; //59999 - gives 1us resolution
	 TIMER0_TCR = 0x1; //
	 while (TIMER0_TC <= usdelay){
	 }
	 TIMER0_TC = 0;
	 TIMER0_TCR = 0;
}
//---------------- end of delayus.c file -----------------------

It's very simple, but it's done and anybody that needs a short delay
can use this instead of make a for next loop....

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.