Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] Re: delay time is not reliable

2012-08-31 by John Samperi

At 12:00 AM 1/09/2012, you wrote:
>When I look at the signal, I get between 0.9 and 2.1ms (about)for a 
>call for 5ms.
>
>When I try 10ms delay, I get between 2 and 4ms delay.

hmm something is fishy, maybe your test equipment? :-)

As you have tried different boards and they were working ok
before that seems to be the most likely problem.

I'm assuming here that your boards are reasonably made with proper
supply bypass and steady supply.

The project I'm currently working on has a 70ms and a 50ms delay and
it is very accurate.

Not trying to teach you anything of course but something like this
could be handy to check your setup.
I have never used anything but the Studio generated makefile so the
F_CPU is entered in the project settings.

#include <avr/io.h>
#include <util/delay.h>

int main(void)
{
         DDRD |= (1 << PD4);

         for( ;; )
         {

     PORTD |= (1 << PD4);
     _delay_ms(500);             //Max 65.535 seconds with latest winAvr
         PORTD &= ~(1 << PD4);
     _delay_ms(500);
         }
}




Regards

John Samperi

********************************************************
Ampertronics Pty. Ltd.
11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
Tel. (02) 9674-6495
Website  http://www.ampertronics.com.au
*Electronic Design * Custom Products * Contract Assembly
********************************************************

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.