AT90S2313-LEDFlasher
This project shows the application of AT90S2313 as LED flasher. It shows four combinations of LED displays, with respect to the inputs that are provided on the PIND.
It uses one AT90S2313 Microcontroller, 8 LEDs, 8 transistors and DC supply.
The program is as shown:
_SREG__ = 0x3f
__SP_H__ = 0x3e
__SP_L__ = 0x3d
__tmp_reg__ = 0
__zero_reg__ = 1
.global __do_copy_data
.global __do_clear_bss
.text
.global main
.type main, @function
main:
;----------------------------------------------------
; LED FLASHER USING AVR 90S2313 MICROCONTROLLER
;------------ MAIN ROUTINE ---------------------------
/* prologue:
frame size=0 */
/* ldi r28,lo8(__stack - 0)
ldi r29,hi8(__stack - 0)
out __SP_H__,r29
out __SP_L__,r28
/* prologue end (size=4) */
ldi r16,0xff
ldi r18,0x7f
ldi r19,0xfe
ldi r21,0x01
ldi r22,0x08
ldi r28,0b11100111
out 0x17,r16 ; Setting the DDRB register as output mode
com r16
out 0x11,r16 ; Setting the DDRD register as input mode
clr r17
l1:
in r16,0x10 ; Inputting the PORTD value to R16
cpi r16,0x00 ; Jump to pattern 0 if equal to 0
breq pattern0
cpi r16,0x01 ; Jump to pattern 1 if equal to 1
breq pattern1
cpi r16,0x02 ; Jump to pattern 2 if equal to 2
breq pattern2
cpi r16,0x03 ; Jump to pattern 3 if equal to 3
breq pattern3
rjmp l1
;-------------------------------------------
; LED BLINKING ON OFF
;-------------------------------------------
pattern0:
com r17
out 0x18,r17
rcall delay
rjmp l1
;--------------------------------------------
; DANCING LED's RIGHT
;--------------------------------------------
pattern1:
out 0x18,r18
sec
ror r18
cpi r18,0xff
breq loop4
rcall delay
rjmp l1
loop4:
ldi r18,0x7f
ret
;---------------------------------------------
; DANCING LED's LEFT
;---------------------------------------------
pattern2:
out 0x18,r19
sec
rol r19
cpi r19,0xff
breq loop7
rcall delay
rjmp l1
loop7:
ldi r19,0xfe
ret
;------------------------------------------
; DANCING LIGHT TWO IN A ROW
;------------------------------------------
pattern3:
;sec
out 0x18,r28
clc
rol r21
ror r22
cpi r21,0x10
breq loop17
cpi r22,0x10
breq loop18
mov r28,r21
mov r29,r22
com r28
com r29
swap r28
andi r28,0xf0
andi r29,0x0f
add r28,r29
; ROTINE FOR PRODUCING DELAY
delay:
ldi r25,0x00
out 0x32,r25
inc r25
ldi r29,0x01
out 0x33,r29
inc r25
out 0x39,r25
sei
ldi r25,0x20
out 0x35,r25
sleep
loop17:
ldi r21,0x08
ldi r22,0x01
ret
loop18:
ldi r21,0x01
ldi r22,0x08
ret
.size main, .-main
.global __vector_6
.type __vector_6, @function
__vector_6:
/* prologue: frame size=0 */
/* prologue end (size=0) */
/* timer0 - interrupt routine
----------------------------*/
ldi r31,0xDF
out __SP_L__,r31
rjmp l1