AT90S2313-16bit-timer1-compare
This is a project that illustrates the application of compare match interrupt
vector in TIMER1. Whenever there is a compare match during the running of
TIMER1, it produces an interrupt and displays ‘33’ in display.
This project uses one AT90S2313 Microcontroller, two Seven-Segment displays, and
two 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 r30,0x00
out 0x18,r30
ldi r16, lo8(0000 ;Initializing the TCNT1L(0x2c) of Timer1
out 0x2C,r16
ldi r16,hi8(0000) ; Initializing the TCNT1H(0x2d) Registers of Timer1
out 0x2D,r16
ldi r16,lo8(-128) ; Loading the OCR1AL(0x2a) with 10000000(0x80)
out 0x2A,r16
ldi r16,hi8(0) ; Loading the OCR1AH(0x2b) with 0
ldi r23, 0xff
out 0x17,r23 ; Setting the ‘DDRB’ Register in Output Mode
out 0x2B,r16
ldi r17,0xc0 ; Enabling the Output Compare Interrupt Enable Bit of ‘TIMSK
‘
out 0x39,r17
sei ; Enabling the Global Interrupt Enable Bit.
ldi r17,0x09
out 0X2E,r17 ; Enabling the ‘TCCR1B’ Register For Starting Timer1.
loop1:
rjmp loop1
;----------------------------------
; TIMER16 - COMPARE ROUTINE
;---------------------------------
.size main, .-main
.global __vector_4
.type __vector_4, @function
__vector_4:
ldi r31,0xDF
out __SP_L__,r31
LDI R20,0X33 ; Outputting 0x33 through PORTB
out 0x18,r20
rjmp main ; Returning to Main