AT90S2313-8bit-UpDownCounter
This project shows the 8bit Timer application of AT90S2313. It is being designed to count from 00-FF at a speed of clk/8. Whenever an over flow occurs it displays odd numbers in the reverse order.
This project database uses one AT90S2313 Microcontroller, two 7-segment displays & 2 display drivers
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:
ldi r21,0x00
ldi r16,0xff
ldi R19,0X02
out 0x32,r21 ; Initializing ‘TCNT0’ Register for Timer 0
out 0x39,r19 ; Setting the TOIE0 Bit of ‘TIMSK’ Register
out 0x17,R16 ; Setting up the ‘DDRB’ Register in Output Mode
sei
ldi r18,0x02
out 0x33,r18 ; Starting the 8-Bit Timer 0
LOOP1:
in r28, 0x32 ; Outputting the TCNT0 value through PORTB
out 0x18 ,R28
rjmp LOOP1
;----- TIMER 0 - INTERRUPT SERVICE ROUTINE----
;------- reverse counting decremented by 2----
; ---------------VECTOR6-------------------
.size main, .-main
.global __vector_6
.type __vector_6, @function
__vector_6:
ldi r18,0x00 ; Stopping the Timer
out 0x33,r18
clc
in r21, 0x18 ; Inputting the PORTB value on R21
LOOP2:
subi r21, 0x02 ; Decrementing R21 by 2
out 0x18, r21 ; Outputting the value through PORTB
brcc LOOP2 ; Checking for Carry Flag
rjmp main