avr-chat
[Top][All Lists]
Advanced

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

Re: [avr-chat] Getting started


From: J D Freeman
Subject: Re: [avr-chat] Getting started
Date: Fri, 4 Jan 2008 23:50:36 +0000
User-agent: Mutt/1.5.17 (2007-11-01)

On Fri, Jan 04, 2008 at 03:09:07PM -0800, Rick Altherr wrote:
> If your switch is betwen PD0 and +5V, why do you need the pullups enabled?  
> That would make it always be +5V since when the switch is off, it would be 
> pulled up by the pull-ups.

Reading the datasheet, setting PORTD to zero should disable the pullups.
To be sure, I tried adding a line to force it:

MCUCR = _BV(PUD);

This makes no difference.

So, either I am not setting the pin's up properly. OR, I am not reading
from them correctly. Or both.

> So, every iteration through the loop, PD0 is checked to see if it is
> 1.
> Because of the above, it always is.  Then, it toggles PC4.  Depending
> on
> how fast the clock is going, this could easily be toggling at a rate
> that
> the naked eye cannot see.  For a 1MHz part, it could take 4 cycles to
> run
> an iteration of the loop, so the LED would be toggling at 250KHz, or
> stated
> another way, would have a 50% duty cycle at 125KHz.

That makes sense. Sticking a delay in the loop just makes it sit there
and flash.

J





reply via email to

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