Hardware Reference
In-Depth Information
Seven-Segment Display
Displayed BCD Digit
Port B
Port P
#5
1
$06
$1F
#4
2
$5B
$2F
#3
3
$4F
$37
#2
4
$66
$3B
#1
5
$6D
$3D
#0
6
$7D
$3E
Table 4.8 Table of display patterns for Example 4.14
Step 2
Output the byte pointed to by ptr to Port B and then increment ptr by 1.
Step 3
Output the byte pointed to by ptr to Port P and then increment ptr by 1.
Step 4
Wait for 1 ms.
Step 5
If (ptr 55 (display 1 12)), then go to step 1;
else, go to Step 2.
The assembly program that implements this algorithm is as follows:
#include
“c:\miniide\hcs12.inc”
org
$1500
start
lds
#$1500
movb
#$FF,DDRB
movb
#$3F,DDRP
forever
ldx
#DispTab
; set X to point to the display table
loopi
movb
1,x 1 ,PTB
; output segment pattern
movb
1,x 1 ,PTP
; output display select
ldy
#1
jsr
delayby1ms
; wait for 1 ms
cpx
#DispTab 1 12
; reach the end of the table?
bne
loopi
bra
forever
#include
“c:\miniide\delay.asm”
DispTab
dc.b
$06,$1F
dc.b
$5B,$2F
dc.b
$4F,$37
dc.b
$66,$3B
dc.b
$6D,$3D
dc.b
$7D,$3E
;
org
$FFFE
; uncomment this line for CodeWarrior
;
dc.w
start
; uncomment this line for CodeWarrior
end
 
Search WWH ::




Custom Search