For your homework, modify the “Display_Speed.asm” program by incorporating the timing routines from the “Ping_Pong Precise Timing.asm” program and show another character on the 4-digit display every 4 ms at a constant rate. (Do not speed up the display sequence).
Then, for your Project credit, run the program on the boards in the Computer lab and demonstrate to the TA. Then increase the time delay between characters by 1 ms at a time and note when the display starts noticeably flickering.
The homework portion of this assignment is due October 2, 2008 and the project portion of the assignment is due October 4, 2008.
************************************************************************* * Assignment #4 / Project #1: Objective is to demonstrate scanned * * multiplexing of four seven segment displays and to find the minimum * * frequency in KHz before the flicker is visible to the user. Then we * * should show other characters on the display and show to our TA. We * * Should be able to perform all tasks with simple modifications of * * instructor provided "Display_Speed.asm" with time delay routine from * * instructor provided "Ping_Pong Precise Timing.asm." * * * * Written for MiniIde Assembler, Sep. 23, 2008, by Dr.M. Giesselmann ************************************************************************* ************************************* * Register Constants (Clock) * ************************************* Eclock EQU 24000000 ;24 MHz CPU Frequency Loops1ms EQU (Eclock/6/1000)-4;Number of Loops for 1.0ms @ 6 cycles per loop * ;Reduce Number of Loops by 2&2 for Overhead DELAY EQU 4 ;Define Delay in ms for Animation Speed *************************** * 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 pg 205 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 BSR Start ;Rince and repeat... ********************************************************* * Time Delay Subroutine, 12 Cycles Overhead inner loop * ********************************************************* TimDel: PSHX ;Push X onto stack to preserve it, 2 Cycles LDX #DELAY ;Load X with number of Loops for 1ms, 2 Cycles Loop: BSR OneMS ;Call 1ms Delay Routine, 4 cycles NOP ;No Operation, padd loop with 1 cycle NOP ;No Operation, padd loop with 1 cycle NOP ;No Operation, padd loop with 1 cycle NOP ;No Operation, padd loop with 1 cycle NOP ;No Operation, padd loop with 1 cycle DBNE X, Loop ;Decrement X and Branch to LoopX if X>0, 3 cycles PULX ;Restore X from Stack, 3 Cycles RTS ;Return from Time Delay Subroutine, 5 Cycles ********************************************************* * 1.0 ms Time Delay Subroutine, 12 Cycles Overhead * ********************************************************* OneMS: PSHX ;Push X onto stack to preserve it, 2 Cycles LDX #Loops1ms ;Load X with number of Loops for 1ms, 2 Cycles LoopX: NOP ;No Operation, padd loop with 1 cycle NOP ;No Operation, padd loop with 1 cycle NOP ;No Operation, padd loop with 1 cycle DBNE X, LoopX ;Decrement X and Branch to LoopX if X>0, 3 Cycles PULX ;Restore X from Stack, 3 Cycles RTS ;Return from Time Delay Subroutine, 5 Cycles *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
| Attachment | Size |
|---|---|
| Display_Speed.asm | 3.79 KB |
| Ping_Pong Prec Timing.asm | 3.61 KB |
| Display_Speed ms.asm | 4.97 KB |
Comments
Post new comment