Yahoo Groups archive

Lpc2000

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

Thread

Trouble with simple delay function :-/

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

Re: Trouble with simple delay function :-/

2004-12-09 by nourson54

I have investigate a little more . It looks like ii's a bug from the
compiler :-/

I set two breakpoints just after the call and it seems the duration
parameter is altered 

void pause(uint32_t duration)
{
  uint32_t startTime = T0TC;      <----- 1st BP here,duration=10000000
	uint32_t now,temp;

	now=startTime;            <-- 2nd BP here,duration=3247832688
	temp=now-startTime;
  while (temp < duration)
		{
			now=T0TC;
			temp=(uint32_t)(now-startTime);
			WDOG();
		}













--- In lpc2000@yahoogroups.com, "nourson54" <yannsuisini@h...> wrote:
Show quoted textHide quoted text
> 
> 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

Re: Trouble with simple delay function :-/

2004-12-09 by nourson54

another strange thing :
10000000 is 0x00989680 

and 3247832688 is 0xC1989680

the compiler seems to alter the high byte of the parameter. 
Whys and how , i don't know ... 

Someone from Rowley here ? :)






--- In lpc2000@yahoogroups.com, "nourson54" <yannsuisini@h...> wrote:
Show quoted textHide quoted text
> 
> I have investigate a little more . It looks like ii's a bug from the
> compiler :-/
> 
> I set two breakpoints just after the call and it seems the duration
> parameter is altered 
> 
> void pause(uint32_t duration)
> {
>   uint32_t startTime = T0TC;      <----- 1st BP here,duration=10000000
> 	uint32_t now,temp;
> 
> 	now=startTime;            <-- 2nd BP here,duration=3247832688
> 	temp=now-startTime;
>   while (temp < duration)
> 		{
> 			now=T0TC;
> 			temp=(uint32_t)(now-startTime);
> 			WDOG();
> 		}
> 
> 















> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> --- In lpc2000@yahoogroups.com, "nourson54" <yannsuisini@h...> wrote:
> > 
> > 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

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.