EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

AVR and dim LEDs.

Started by artswan December 2, 2006
I used the same LED that I was using in a breadboarded PIC circuit, a
pretty standard red LED I had bought in bulk from All Electronics a
year or two ago. I also switched out with other red LEDs that I knew
worked well. Same result, dim flashing LED. And, since I was using a
short flash time (0.250 seconds) for both on and off states, and was
running the circuit for only a few seconds to test it, I even took the
220 ohm resistor I was using in series with the LED and connected the
LED directly from the output pin to ground. Same dim flashing LED.

Art

Oh, one final note that I forgot to mention (silly me!), I connected
the LED, both with a series 220 ohm resistor and without, from Vdd to
the output pin, so as to have the AVR chip sink current rather than
source it, and there was no longer any visible blinking of the LED.

Art

artswan wrote:

> Oh, one final note that I forgot to mention (silly me!), I connected > the LED, both with a series 220 ohm resistor and without, from Vdd to > the output pin, so as to have the AVR chip sink current rather than > source it, and there was no longer any visible blinking of the LED.
You are risking damage to the LED and/or the chip by connecting it without a resistor. Anyway, it looks like your problem is that you haven't set the pin to output mode. for example if it was pin 0 on port C you would use: sbi DDRC,0 When the data direction bit is low the port bit just switches on or off a pull-up resistor. That would explain the symptoms you are getting. -- Mike
artswan wrote:
> Hello all. I have been working with PIC microcontrollers for over 2 > years now and I am familiar with and like them. However, recently I > have started dabbling with Atmel AVR microcontrollers to see what they > have to offer. Especially, since they seem quite popular these days and > are showing up in more open-source products. I have done some simple > flashing LED circuits with the ATmega8 and 48, and the ATtiny2313. I > have been using the demo version of BASCOM and have just been doing > simple one and two LED flashing circuits with very simple programs. The > programs all seem to work fine on each of the chips. I have noticed, > though, that the LEDs do not flash nearly as brightly with the AVR > chips as they do with the PIC chips. Is that something unique to AVR > chips, or is there some sort of pull-up resistor or other switch that > needs to be set to allow for more current to pass throught the LED?
Yes there is, all PIC output pins have high current capability and can drive a LED directly, the ATmega's have high and low current ports, usually port B is the high current port and should be able to drive an LED directly like the PIC (at 5 volts anyway). So move the LED to a high current pin and you should work the same as the PIC. In general the AVR's are lower power devices, optimized for battery power (more delicate), so they make sacrifices like this.
Mike Warren wrote:
> artswan wrote: > > > Oh, one final note that I forgot to mention (silly me!), I connected > > the LED, both with a series 220 ohm resistor and without, from Vdd to > > the output pin, so as to have the AVR chip sink current rather than > > source it, and there was no longer any visible blinking of the LED. > > You are risking damage to the LED and/or the chip by connecting it > without a resistor. > > Anyway, it looks like your problem is that you haven't set the pin to > output mode. > > for example if it was pin 0 on port C you would use: > > sbi DDRC,0 > > When the data direction bit is low the port bit just switches on or off > a pull-up resistor. That would explain the symptoms you are getting.
I agree, that's exactly what it looks like. Note that the PIC uses '0' in the direction register to turn a pin into an output, while the AVR uses '1'.

The 2024 Embedded Online Conference