S3C80A5B
BASIC TIMER AND TIMER 0
10-9
F
Programming Tip — Programming Timer 0
This sample program sets timer 0 to interval timer mode, sets the frequency of the oscillator clock, and determines
the execution sequence which follows a timer 0 interrupt. The program parameters are as follows:
— Timer 0 is used in interval mode; the timer interval is set to 4 milliseconds
— Oscillation frequency is 6 MHz
— General register 60H (page 0)
←
60H + 61H + 62H + 63H + 64H (page 0) is executed after a timer 0 interrupt
ORG
0FAH
; Timer 0 overflow interrupt
VECTOR
T0OVER
ORG
0FCH
; Timer 0 match/capture interrupt
VECTOR
T0INT
ORG
0100H
RESET
DI
; Disable all interrupts
LD
BTCON,#0AAH
; Disable the watchdog timer
LD
CLKCON,#18H
; Select non-divided clock
CLR
SYM
; Disable global and fast interrupts
CLR
SPL
; Stack pointer low byte
←
"0"
; Stack area starts at 0FFH
•
•
•
LD
T0CON,#4BH ;
Write '01001011B'
; Input clock is f
OSC
/256
; Interval timer mode
; Enable the timer 0 interrupt
; Disable the timer 0 overflow interrupt
LD
T0DATA,#5DH
; Set timer interval to 4 milliseconds
; (6 MHz/256)
÷
(93 + 1) = 0.25 kHz (4 ms)
SRP
#0C0H
; Set register pointer
←
0C0H
EI
; Enable interrupts
•
•
•