lighting LEDs

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, I managed to get my Atmega8 to connect to my programmer, and have tried to write a simple program to test it. I wired up 8, 5volt LED's through 390R resistors between port D and the 5 volt rail. I then built the following code, and burnt the hex file to the avrs flash (all using AVRstudio):

.NOLIST
.INCLUDE "m8def.inc"
.LIST

.DEF mpr=R16

LDI mpr,0b01010101
OUT PORTD, mpr

The LED's didn't light, so I tried instead connecting them between ground and portd (reversing their polarity also), but still no luck.

When debugging, it shows R16's value to be 0x55 which is correct, and yet for some reason it isn't working in the circuit.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You aren't setting PORTD as output. Add a:

LDI mpr, 0xFF
OUT DDRD, mpr

at the very start.

Also consider where control goes next after your last "OUT PORTD, mpr" instruction