*************************************************************************
* Program to demonstrate multiplex Speed on theDragon 12 Eval Board *
* A multiplexed 7 Segment Display is connected to PORT B *
* The individual Digits are controlled (neg.logic) by Pins Port P0...P3 *
* Written for Dragon 12 Eval Board *
* Written for MiniIde Assembler, Sep. 22, 2008, by M. Giesselmann *
*************************************************************************
***************************
* 68HC12 Register Equates *
***************************
PORTB EQU $0001 ;Port B I/O Data Register
DDRB EQU $0003 ;Port B Data Direction Register
PTP EQU $0258 ;Port P I/O Data Register
DDRP EQU $025A ;Port P Data Direction Register
************************************
* Start (ORIGIN) of Code in Memory *
************************************
ORG $1000 ;Origin=Bottom of User RAM
Init: BSET DDRB, $FF ;Make all Bits of Port B Outputs
BCLR PORTB, $FF ;Clear all Bits of Port B;turn all Segments off
BSET DDRP, $0F ;Make lower 4 bits of Port P Outputs
LDX #SegCde ;Load start of Code Lookup table into X
Slow: MOVW #800,DELAY ;Initialize Delay count
Start: BSET PTP, $0F ;Turn all Digits off
BCLR PTP, $01 ;Turn Digit 4 ON
MOVB 1,X, PORTB ;Display "1" on multiplexed 7 Segment Display
BSR TimDel ;Branch to Time Delay Subroutine, rel. adressing
BSET PTP, $0F ;Turn all Digits off
BCLR PTP, $02 ;Turn Digit 3 ON
MOVB 2,X, PORTB ;Display "2" on multiplexed 7 Segment Display
BSR TimDel ;Branch to Time Delay Subroutine, rel. adressing
BSET PTP, $0F ;Turn all Digits off
BCLR PTP, $04 ;Turn Digit 2 ON
MOVB 3,X, PORTB ;Display "3" on multiplexed 7 Segment Display
BSR TimDel ;Branch to Time Delay Subroutine, rel. adressing
BSET PTP, $0F ;Turn all Digits off
BCLR PTP, $08 ;Turn Digit 1 ON
MOVB 4,X, PORTB ;Display "4" on multiplexed 7 Segment Display
BSR TimDel ;Branch to Time Delay Subroutine, rel. adressing
LDD DELAY ;Load Double Accu with DELAY Value
SUBD #$0004 ;Subtract $0004 from Double Accu
STD DELAY ;Store Double Accu back at DELAY
CPD #$0040 ;Compare Result with $0040
BHS Start ;Start back at the Beginning if Higher or Same
BRA Slow ;Re-Initialize DELAY
*******************************************
* Time Delay Subroutine with nested Loops *
*******************************************
TimDel: PSHX ;Push X onto Stack
PSHY ;Push Y onto Stack
LDY DELAY ;Load Y Register with DELAY
LoopX: LDX DELAY ;Load X Register with DELAY
DecX: DEX ;Decrement X Register
BNE DecX ;Branch if DELAY limit has not been reached
DEY ;Decrement Y Register
BNE LoopX ;Branch if DELAY limit has not been reached
PULY ;Restore Y from Stack
PULX ;Restore X from Stack
RTS ;Return from DELAY Subroutine
*Definition of symbols
* 0 1 2 3 4 5 6 7 8 9 A b C d E F
* - - - - - - - - - - - -
* | | | | | | | | | | | | | | | | | | | | |
* - - - - - - - - - - - -
* | | | | | | | | | | | | | | | | | | | | | |
* - - - - - - - - - - -
*********************************
* Set up Symbol Table in Memory *
*********************************
SegCde: FCB $3F ;$3F = Code for 0
FCB $06 ;$06 = Code for 1
FCB $5B ;$5B = Code for 2
FCB $4F ;$4F = Code for 3
FCB $66 ;$66 = Code for 4
FCB $6D ;$6D = Code for 5
FCB $7D ;$7D = Code for 6
FCB $07 ;$07 = Code for 7
FCB $7F ;$7F = Code for 8
FCB $6F ;$6F = Code for 9
FCB $77 ;$77 = Code for A
FCB $7C ;$7C = Code for B
FCB $39 ;$39 = Code for C
FCB $5E ;$5E = Code for D
FCB $79 ;$79 = Code for E
FCB $71 ;$71 = Code for F
DELAY: RMB 2 ;Reserve 2 Bytes of Memory for Delay count
Recent comments
1 week 1 day ago
1 week 1 day ago
1 week 1 day ago
2 weeks 19 hours ago
2 weeks 6 days ago
3 weeks 7 hours ago
3 weeks 8 hours ago
9 weeks 12 hours ago
12 weeks 6 days ago
13 weeks 5 days ago