AT90S8515 Question

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

I want to hook up an LED on pin1 (portB) and make it light up. What assembly code does this. An example would be nice :) tks in advance. Dan.

admin's test signature
 

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

This is a program I found at www.avr-forum.com. It should do as a starting point and give you an idea how to program...

Don't forget the current limiting resistor (about 470 ohms at 5V).

Hardware:
Connect: +5V--resistor 470 ohm--LED--PIN. Otherwise your controller (pin) might be gone and you won't notice...

To be programed:
Basic procedure for all AVR controllers:
1) set the pin direction bit: marked with (1) in the sample
2) write a "0" the appropriate pin: marked with (2)

hint: read the corresponding manuals for the controller (especially the section about PORTS). You can find them under the tab "devices" on this site. They will give you vast amounts of information.

Chris

/////////////////////////

; Bit rotation test program for Atmel AVR microcontrollers
; Ingeneering Inc.
; www.ingeninc.com
; Jeff Holtzman
; 2/4/98

;Description
;Rotates a bit through LEDs using precise software time
;delay. From 10/98 issue of Popular Electronics magazine.
;AUTHOR = Jeff Holtzman
;TARGET = AT90S1200

; change the device to the one, you use (chris!)

.device AT90S1200
.cseg
.org 0

.equ DDRB = $17
.equ PORTB = $18
.equ OLC = 0 ; outer loop count for delay routine
.equ ILC = 156 ; inner loop count for delay routine

RESET: ldi r16, 255
(1) out DDRB, r16 ; set port B for all outputs

ldi r16, $FE ; initially enable just the lowest bit
LOOP: sec
(2) out PORTB, r16 ; turn on one LED

ldi r17, 5 ; wait 0.5 sec
LP1: rcall DELAY
dec r17
brne LP1

rol r16 ; rotate the bit
cpi r16, $FF ; if all bits not set
brne LOOP ; ... continue
dec r16 ; else set just the lowest bit
rjmp LOOP ; loop forever

DELAY: ldi r22, OLC ; delay for 1/10th second
DL1: ldi r23, ILC
DL2: rcall DUMMY ; waste 7 cycles
dec r23
brne DL2
dec R22
brne DL1
DUMMY: ret

admin's test signature
 

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

Thanks for the help... it works perfectly... I had the LED hooked wrong, but works fine now.
Dan.

admin's test signature