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
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).
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.
; Bit rotation test program for Atmel AVR microcontrollers
; Ingeneering Inc.
; Jeff Holtzman
;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!)
.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
(2) out PORTB, r16 ; turn on one LED
ldi r17, 5 ; wait 0.5 sec
LP1: rcall DELAY
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
Thanks for the help... it works perfectly... I had the LED hooked wrong, but works fine now.
©2015 Atmel Corporation