-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLEDdemo.asm
53 lines (42 loc) · 1.96 KB
/
LEDdemo.asm
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
PAGE 0 ; suppress page headings in ASW listing file
cpu MK3850
;========================================================================
; a simple application used to demonstrate the hex file download function
;========================================================================
; port address
serialport equ 00H
LEDport equ 01H
; scratchpad RAM
delaycnt equ 07H ; scratchpad RAM
loopcnt equ 08H ; scratchpad RAM
org 8000H
; since the outputs of port 4 are open drain, writing '1' to a port 4 output port pin
; results in a '0' at that output port pin. the cathodes of the LEDs are connected to
; the output pins of port 4, therefore, outputing '1' pulls the cathode low and turns
; the LED on. outputing '0' turns the LED off.
start: clr
outs LEDport
outs serialport
loop: ins LEDport
inc
outs LEDport ; output A to port 0
li 100
lr delaycnt,A
pi delay ; delay 100*10 mSec
br loop
;------------------------------------------------------------------------
; delay = 10 mSec times the number in 'delaycnt'
;------------------------------------------------------------------------
delay: clr ; 1 cycle
lr loopcnt,A ; 2 cycles
delay1: in 0FFH ; 4 cycles
in 0FFH ; 4 cycles
in 0FFH ; 4 cycles
in 0FFH ; 4 cycles
nop ; 1 cycles
ds loopcnt ; 1.5 cycles
bnz delay1 ; 3.5 cycles
ds delaycnt ; 1.5 cycles
bnz delay ; 3.5 cycles
pop ; 2 cycles
end start