⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hexledpattern.asm

📁 Alarm clock with PIC microcontroller
💻 ASM
字号:
;==============================================================================
; Hexadecimal LED Patterns
;------------------------------------------------------------------------------

;==============================================================================
; Revision History:
;
; 2005-02-20 AJ Corrected LED patterns for 6 and 9.
; 2005-02-06 AJ Updated to used the configuration file constants for LED bits.
; 2004-12-29 AJ Initial version;
;------------------------------------------------------------------------------

                include ../pic.inc
                include config.inc

                global  HexLedPattern

                extern  SCRATCH

;==============================================================================
; Define some aliases for the segment bits

SA              equ     SEGMENT_A
SB              equ     SEGMENT_B
SC              equ     SEGMENT_C
SD              equ     SEGMENT_D
SE              equ     SEGMENT_E
SF              equ     SEGMENT_F
SG              equ     SEGMENT_G

;==============================================================================

                code

; Convert the 0-F value in the W register into a bit pattern to drive a seven
; segment display. No checks are applied to the input value.
;
; This routine changes register bank and cannot be re-entered until complete.
;
; Words: 24/26  Cycles: 11/13  Stack Depth: 0

HexLedPattern:
                banksel SCRATCH         ; Switch to scratch bank and 
                movwf   SCRATCH         ; .. save the digit value.
                movlw   high Values     ; Set PCLATH to high portion of
                movwf   PCLATH          ; .. jump table address
                movlw   low  Values     ; Compute the low portion of
                addwf   SCRATCH,W       ; .. the target jump address
                skpnc                   ; Correct PCLATH if we cross a page
                incf    PCLATH,F        ; .. boundary
                movwf   PCL             ; Then goto to jump table entry

; Bit patterns for hexadecimal digits

Values          retlw   SA|SB|SC|SD|SE|SF       ; 0
                retlw      SB|SC                ; 1
                retlw   SA|SB|   SD|SE|   SG    ; 2
                retlw   SA|SB|SC|SD|      SG    ; 3
                retlw      SB|SC|      SF|SG    ; 4
                retlw   SA|   SC|SD|   SF|SG    ; 5
                retlw   SA|   SC|SD|SE|SF|SG    ; 6
                retlw   SA|SB|SC                ; 7
                retlw   SA|SB|SC|SD|SE|SF|SG    ; 8
                retlw   SA|SB|SC|SD|   SF|SG    ; 9
                retlw   SA|SB|SC|   SE|SF|SG    ; A
                retlw         SC|SD|SE|SF|SG    ; b
                retlw   SA|      SD|SE|SF       ; C
                retlw      SB|SC|SD|SE|   SG    ; d
                retlw   SA|      SD|SE|SF|SG    ; E
                retlw   SA|         SE|SF|SG    ; F

                end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -