avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] generating a delay


From: varsha
Subject: Re: [avr-gcc-list] generating a delay
Date: Tue, 25 Oct 2005 12:20:19 +0530

hi!!
i used the delay routines defined in avr/delay.h file, for generating microseconnd and ms delays.
for generating delay of nanoseconds,
u can take a variable which is declared globally,
or a variable declared with volatile keyword...
asign some value to it..it will generate a small delay in nanoseconds...
 
----- Original Message -----
To: varsha
Sent: Monday, October 24, 2005 1:13 PM
Subject: RE: [avr-gcc-list] generating a delay

Don’t know about it being a ‘proper’ way but you could do a bit of inline assembler…

 

            ldi         r16,       0

start_loop:

            nop                                           ; nop or 2

            inc        r16

            cpi        r16,       ( a value )

            brne      start_loop

 

and count the clocks to work out  ( a value ) for the right delay at 8mhz. Timer/sleep could be better for 25ms though as this is the processing-intensive way ;P

See if you can find an implementation of nanosleep!

 

seb

 

 

-----Original Message-----
From: varsha [mailto:address@hidden
Sent:
Monday, 24 October 2005 4:38 PM
To: address@hidden
Subject: [avr-gcc-list] generating a delay

 

Hello all,

I'm working on avr-gcc (GCC) 3.4.3

Atmega 16 controller, clock frequecy is 8 MHz,

and i want to generate a delay of 25ms.

and i wrote one routine for the same..

and called it in other function as

delay(250,0xff);

-

-

- but i think it is not generating the correct value...

---------------------------------------------------------------------------------------

void delay_ms(unsigned char count1,unsigned char count)
{
 unsigned char j,i;
 while(count1--)
  {
    while(count--)
   {
    i++;
    j++;
   }  
  }
}

 what is the proper way to write a delay routine?

 

 

 

regards,
varsha


--

***********************Confidentiality Notice***************************
The information contained in this electronic message and any attachments
to this message are intended for the exclusive use of the addressee(s)
and may contain confidential or privileged information. If you are not
the intended recipient, please notify the sender at Divinet or
address@hidden immediately and destroy all copies of this
message and any attachments.

************************************************************************
This email (the term email includes any files transmitted with it) is supplied commercial in confidence and may be legally privileged. If not the intended recipient, you must not read, use or disseminate the email and are to notify the sender immediately. No guarantee is made that this email is free of errors, omissions, virus or interference and no liability is accepted by Robway (Robway Crane Safety Systems P/L) relating to the receiving of this email.  The views expressed in this email are those of the author and may not reflect the views of Robway. Please note that emails sent to and from Robway may be monitored.

 

 


Internal Virus Database is out-of-date.
Checked by AVG Anti-Virus.
Version: 7.0.322 / Virus Database: 267.11.9/115 - Release Date: 9/29/05

--

***********************Confidentiality Notice***************************
The information contained in this electronic message and any attachments
to this message are intended for the exclusive use of the addressee(s)
and may contain confidential or privileged information. If you are not
the intended recipient, please notify the sender at Divinet or
address@hidden immediately and destroy all copies of this
message and any attachments.

************************************************************************

reply via email to

[Prev in Thread] Current Thread [Next in Thread]