213/317
7 - Debugger and PROM Programmer Tutorial for ST72251
The source code for the main program and for the multitasking kernel follow. First, the main
program:
ST7/
;==================================================================
;=
Demonstration of a simplified real-time cooperative kernel
=
;==================================================================
; This program performs a voltage to frequency conversion on four
; independent channels.
; Pc0 through Pc3 are the analog inputs,
; Pa0 through Pa3 are the corresponding outputs (blinking led's).
; Declaration of the macro that provides the code for all tasks.
; =================
TASK
MACRO
Channel
LOCAL TaskLoop,InnerLoop,TaskCont
TaskLoop:
ld A,#{Channel-1}
; Pc0 analog input
call acana
; Convert voltage
ld X, adcdr
ld A, (TimingTable,X)
; Get result of timing function from
table
ld reg&Channel, A
InnerLoop:
ld A, reg&Channel
tnz A
jreq TaskCont
; Yield until timing register = 0
call Yield
jra InnerLoop
TaskCont:
ld A, #{1 SHL {Channel-1}}; When register is zero, toggle output
xor A, padr
ld padr, A
jra TaskLoop
; Continue looping for this task
MEND
#include "Register.inc"
EXTERN StartTasks, Yield, acana
PUBLIC watch, AddrTasks
; Constants
; ==========
cpudiv2.b
EQU 0
; CPU clock ratio 1/2
watch.b
EQU $7F
; Watchdog reload value
t_timer.b
EQU $14
; 10 ms timer reload value
; Registers
; =========
Segment 'ram0'
reg1.b
DS.B 1
; Timing register 1
reg2.b
DS.B 1
; Timing register 2
reg3.b
DS.B 1
; Timing register 3
reg4.b
DS.B 1
; Timing register 4
Segment 'rom'
; set in ANACLMAP.ASM to E000h
Words
; Table of start adresses of each task
Содержание ST7 Series
Страница 1: ...ST7 8 BIT MCU FAMILY USER GUIDE JANUARY 1999 1 ...
Страница 238: ...238 317 8 C Language and the C Compiler 08 Burn bmp Then use the EPROMer programmer software as described in Chapter 7 ...
Страница 289: ...289 317 10 Second Application a Sailing Computer 10 befor Bs Rw Vw VMG AlphaR AlphaV Before the wind ...