AT90S2313-Up-Down-Counter
This project shows the application of AT90S2313 as Up - Down counter, which
displays numbers from 0-F in Incrementing and Decrementing mode.
This database contains Two Dot Matrix Displays and One AT90S2313 Microcontroller.
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 Routine -------------------
main:
/* 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 r24,0xf0 ; Loading the R24 with 0xf0
LDI r28,0x00 ; loading 0's to R28
LDI r29,0xff
OUT 0x17,r29 ; setting the DDRB register as output mode
loop1:
OUT 0x18,r24 ;outputting the value of R24 through PORTB
INC r28 ; incrementing R28
DEC r29 ; decrementing R29
CLZ
CPI r29,0x0f ; comparing R29 with 0x0f if equal jump to main
BREQ main
MOV r24,r29 ; moving value of R29 to R24
ANDI r24,0x0f ; suppressing higher bit values of R24 by 0's
ANDI r28,0x0f ; suppressing higher bit values of R28 by 0's
SWAP r24 ; swapping R24
ADD r24,r28 ; adding the value of R28 with R24
RJMP loop1 ; jumps to label ‘loop1’