Samsung S3F80JB User Manual page 254

8-bit cmos microcontrollers
Table of Contents

Advertisement

S3F80JB
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
VECTOR 00FAH,T0OVER
VECTOR 00FCH ,T0INT
ORG
RESET:
DI
LD
LD
CLR
CLR
LD
LD
SRP
EI
T0INT:
PUSH RP0
SRP0 #60H
INC
ADD
ADC
ADC
(Continued on next page)
0100H
BTCON,#0AAH
CLKCON,#18H
SYM
SPL
T0CON,#4BH
T0DATA,#5DH
#0C0H
R0
R2,R0
R3,R2
R4,R0
; Timer 0 overflow interrupt
; Timer 0 match/capture interrupt
; Disable all interrupts
; Disable the watchdog timer
; Select non-divided clock
; Disable global and fast interrupts
; Stack pointer low byte → "0"
; Stack area starts at 0FFH
; Write '00100101B'
; Input clock is f
/256
OSC
; Interval timer mode
; Enable the timer 0 interrupt
; Disable the timer 0 overflow interrupt
; Set timer interval to 4 milliseconds
; (6 MHz/256) ÷ (93 + 1) = 0.25 kHz (4 ms)
; Set register pointer → 0C0H
; Enable interrupts
; Save RP0 to stack
; RP0 ← 60H
; R0 ← R0 + 1
; R2 ← R2 + R0
; R3 ← R3 + R2 + Carry
; R4 ← R4 + R0 + Carry
BASIC TIMER and TIMER 0
10-11

Advertisement

Table of Contents
loading

Table of Contents