EasyManua.ls Logo

ST ST7 - Page 213

ST ST7
317 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
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

Table of Contents

Related product manuals