-
Notifications
You must be signed in to change notification settings - Fork 0
/
processA.a51
72 lines (55 loc) · 1.02 KB
/
processA.a51
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
$NOMOD51
#include <Reg517a.inc>
NAME processA
EXTRN DATA (processTable)
PUBLIC processA
; create code segment for this process
processASegment SEGMENT CODE
RSEG processASegment
processA:
; set stackpointer relative to the
; processTable
MOV A, #processTable
ADD A, #4D
MOV SP, A
; magic loop number
MOV R5, #0xF6
mainLoop:
CALL printAToUART
CALL waitRoutine
JMP mainLoop
; write the character 'a' to UART0
printAToUART:
MOV S0BUF, #'a'
waitForSendFinished:
MOV A, S0CON
JNB ACC.1, waitForSendFinished
; reset TI0
ANL A, #11111101b
MOV S0CON, A
RET
; loops for about 1 second
waitRoutine:
; enable timer0
MOV A, TCON
ORL A, #00010000b
MOV TCON, A
; wait for timer0 overflow
timerPollingLoop:
MOV A, TCON
JNB ACC.5, timerPollingLoop
CALL resetWD
; reset TCON
MOV A, TCON
ANL A, #11011111b
MOV TCON, A
; return to timerPollingLoop if
; routine did not wait 1s
DJNZ R5, timerPollingLoop
RET
resetWD:
; reset watchdog timer
SETB WDT
SETB SWDT
RET
END