pickitled.asm

来自「Alarm clock with PIC microcontroller」· 汇编 代码 · 共 92 行

ASM
92
字号
;==============================================================================
; PICKit1 LED Patterns
;------------------------------------------------------------------------------

; Notes:
;
; The Microchip PICKit(tm) 1 uses a multiplexed output scheme which allows its
; 8 (or 12) LEDs to be enabled using only four pins. Any of the LEDs can be
; enabled individually using the TRIS and I/O settings shown in following
; table.
;
; PIN D0  D1  D2  D3  D4  D5  D6  D7  D8  D9  D10 D11
; GP4 HI  LOW HI  LOW Z   Z   Z   Z   Z   Z   HI  LOW
; GP5 LOW HI  Z   Z   HI  LOW Z   Z   HI  LOW Z   Z
; GP2 Z   Z   LOW HI  LOW HI  HI  LOW Z   Z   Z   Z
; GP1 Z   Z   Z   Z   Z   Z   LOW HI  LOW HI  LOW HI

;==============================================================================
; Revision History:
;
; 2005-01-01    Initial version
;------------------------------------------------------------------------------

                include ../pic.inc

                if      PICKIT_ONE

                global  PICKitLedState
                global  PICKitLedValue

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

                code

; Returns the TRIS bit pattern associated with GP1, GP2, GP4 and GP5
; corresponding to the value 0 - 11 in W on entry.
;
; The same TRIS pattern is used for consecutive LEDs so we can divide the input
; value by two and use a shorter data table to save space.

PICKitLedState:
                movwf   PCLATH
                bcf     STATUS,C
                rrf     PCLATH,F
                movlw   high States
                xorwf   PCLATH,F
                xorwf   PCLATH,W
                xorwf   PCLATH,F
                addlw   low States
                skpnc
                incf    PCLATH,F
                movwf   PCL

States          retlw   (1<<2)|(1<<1)           ;D0/1
                retlw   (1<<5)|(1<<1)           ;D2/3
                retlw   (1<<4)|(1<<1)           ;D4/5
                retlw   (1<<5)|(1<<4)           ;D6/7
                retlw   (1<<4)|(1<<2)           ;D8/9
                retlw   (1<<5)|(1<<2)           ;D10/11

;------------------------------------------------------------------------------

; Returns the I/O bit pattern associated with GP1, GP2, GP4 and GP5
; corresponding to the value 0 - 11 in W on entry.

PICKitLedValue:
                movwf   PCLATH
                movlw   high Values
                xorwf   PCLATH,F
                xorwf   PCLATH,W
                xorwf   PCLATH,F
                addlw   low Values
                skpnc
                incf    PCLATH,F
                movwf   PCL

Values          retlw   (1<<4)                  ;D0
                retlw   (1<<5)                  ;D1
                retlw   (1<<4)                  ;D2
                retlw   (1<<2)                  ;D3
                retlw   (1<<5)                  ;D4
                retlw   (1<<2)                  ;D5
                retlw   (1<<2)                  ;D6
                retlw   (1<<1)                  ;D7
                retlw   (1<<5)                  ;D8
                retlw   (1<<1)                  ;D9
                retlw   (1<<4)                  ;D10
                retlw   (1<<1)                  ;D11

                endif
                end

⌨️ 快捷键说明

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