Yahoo Groups archive

Lpc2000

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

Message

Trouble with simple delay function :-/

2004-12-09 by nourson54

I have written a pause() fonction under crossworks 1.3 like this :

#define ONE_SEC (uint32t)10000000

void pause(uint32_t duration)
{
  uint32_t startTime = T0TC;
  uint32_t now,temp;

  now=startTime;
  temp=now-startTime;
  while (temp < duration)
    {
	now=T0TC;
	temp=(uint32_t)(now-startTime);
	WDOG();
    }
}

main
{
    Inittimer, ports, etc ....

    while(1)
       {
           pause(ONE_SEC);
           IOPIN^=LED;
       }



Then when i want to use this function , it happens strange things :
the first time I calls pause() , when i set a brekpoint on the
function pause the parameter duration passed has a value of 3248002688
instead of 10000000 !!! But at the second call(and others)
duration=ONE_SEC=1000000 in pause() . So my led blink at the good
frequency of 1s . 
So , what's wrong ??


thanks in advance

Attachments

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.