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

📄 fc430_es417_cce.asm

📁 lcdcdode cor customized
💻 ASM
📖 第 1 页 / 共 4 页
字号:
            mov.w   IROP2H, R14             ; Load the remainder from div oper
            mov.w   &LCD, R15               ; Set up the pointer to LCD table
            add.w   R8, R15                 ; Add the offset into the LCD table
            mov.b   LCD_Table(R14), 0(R15)  ; Update the actual LCD memory
            mov.w   #0, IROP2H              ; Divide by 10 to get the dividend
            mov.w   R10, IROP2L             ; Load the quotient
            mov.w   #0x0A, IROP1            ; Load the divisor
            call    #UDIV_32_16             ; Value = value / 10
            mov.w   IRACCL, R10             ; Load the dividend from the div op
            add.w   #0x01, R8               ; Increment loop counter
            jmp     dV1                     ; Repeat the loop
dV2:        mov.w   &LCD, R15               ; LCD[i] = LCD_Table[value]
            add.w   R8, R15                 ; Move the retrieved value to reg
            mov.b   LCD_Table(R10), 0(R15)  ; Set the actual LCD memory byte
            cmp.w   #0x00, R9               ; Sign = 0 ?
            jeq     dV3                     ; Yes, so do the jump
            mov.w   &LCD, R15               ; LCD[i-1] = LCD_Table[17];
            add.w   R8, R15                 ; Move the retrieved value to reg
            mov.b   &LCD_Table+17,0xFFFF(R15); Update the actual LCD memory
dV3:        ret                             ; Return from subroutine

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

dispTemp:   mov.w   &tempDegF, R11          ; Fetch the current temp reading
            mov.w   #0x06, R10              ; Start position = 6
            mov.b   #0x00, &LCDM1           ; Clear the LCD memory
            mov.b   #0x00, &LCDM2           ; Clear the LCD memory
            mov.b   #0x00, &LCDM3           ; Clear the LCD memory
            mov.w   R10, R14                ; Set up parameter #1 for func call
            mov.w   R11, R12                ; Set up parameter #2 for func call
            call    #dispValue              ; Call function to display on LCD
            ret                             ; Return from subroutine

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

dispTach:   mov.w   R12, R10                ; Display tachometer on LCD screen
            mov.w   #0x03, R11              ; Init temp register for param #1
            mov.b   #0x00, &LCDM4           ; Clear the LCD memory
            mov.b   #0x00, &LCDM5           ; Clear the LCD memory
            mov.b   #0x00, &LCDM6           ; Clear the LCD memory
            mov.b   #0x00, &LCDM7           ; Clear the LCD memory
            mov.w   R11, R14                ; Set up parameter #1 for func call
            mov.w   R10, R12                ; Set up parameter #2 for func call
            call    #dispValue              ; Call function to display on LCD
            ret                             ; Return from subroutine

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

dispLevel:  mov.b   #0x00, &LCDM8           ; Display system level & bar on LCD
            and.b   #0xF0, &LCDM9           ; Clear lower byte of LCD memory
            mov.b   R12, R14                ; Init temp register with param #1
            sub.b   #0x00, R14              ; Check if level needs to be at 0
            jeq     dLevel0                 ; Yes so jump to set the level to 0
            sub.b   #0x01, R14              ; Check if level needs to be at 1
            jeq     dLevel1                 ; Yes so jump to set the level to 1
            sub.b   #0x01, R14              ; Check if level needs to be at 2
            jeq     dLevel2                 ; Yes so jump to set the level to 2
            sub.b   #0x01, R14              ; Check if level needs to be at 3
            jeq     dLevel3                 ; Yes so jump to set the level to 3
            sub.b   #0x01, R14              ; Check if level needs to be at 4
            jeq     dLevel4                 ; Yes so jump to set the level to 4
            sub.b   #0x01, R14              ; Check if level needs to be at 5
            jeq     dLevel5                 ; Yes so jump to set the level to 5
            jmp     dLevDone                ; Go to done
dLevel0:    mov.b   &LCDM8, &LCDM8          ; Set LCD memory to display level 0
            jmp     dLevDone                ; Go to done
dLevel1:    bis.b   #0x10, &LCDM8           ; Set LCD memory to display level 1
            bis.b   #0x03, &LCDM9           ; S17:S16
            jmp     dLevDone                ; Go to done
dLevel2:    bis.b   #0x20, &LCDM8           ; Set LCD memory to display level 2
            bis.b   #0x07, &LCDM9           ; S17:S16
            jmp     dLevDone                ; Go to done
dLevel3:    bis.b   #0x40, &LCDM8           ; Set LCD memory to display level 3
            bis.b   #0x0F, &LCDM9           ; S17:S16
            jmp     dLevDone                ; Go to done
dLevel4:    bis.b   #0x88, &LCDM8           ; Set LCD memory to display level 4
            bis.b   #0x0F, &LCDM9           ; S17:S16
            jmp     dLevDone                ; Go to done
dLevel5:    bis.b   #0x0F, &LCDM8           ; Set LCD memory to display level 5
            bis.b   #0x0F, &LCDM9           ; S17:S16
dLevDone:   ret                             ; Return from subroutine

;------------------------------------------------------------------------------
                                            ; Display all icons on LCD screen
dispAcc:    mov.b   #0xFF, &LCDM8           ; Enable all LCD segments in byte
            mov.b   #0xFF, &LCDM9           ; Enable all LCD segments in byte
            mov.b   #0xFF, &LCDM10          ; Enable all LCD segments in byte
            mov.b   #0xF7, &LCDM11          ; Enable all LCD segments in byte
            ret                             ; Return from subroutine

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

dispUpArrow:                                ; Display the UP arrow on LCD
            and.b   #0x0F, &LCDM9           ; Clear all arrow segments first
            bis.b   #BIT4, &LCDM9           ; Enable the UP arrow segment
            ret                             ; Return from subroutine

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

dispDownArrow:                              ; Display the DOWN arrow on LCD
            and.b   #0x0F, &LCDM9           ; Clear all arrow segments first
            bis.b   #BIT6, &LCDM9           ; Enable the DOWN arrow segment
            ret                             ; Return from subroutine

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

rotateArrows:
            mov.w   &arrowState, R15        ; Rotate arrows once circular
            sub.w   #0x00, R15              ; Is current state at 0 ?
            jeq     rArrow0                 ; Yes, jump to state 0
            sub.w   #0x01, R15              ; Is current state at 1 ?
            jeq     rArrow1                 ; Yes, jump to state 1
            sub.w   #0x01, R15              ; Is current state at 2 ?
            jeq     rArrow2                 ; Yes, jump to state 2
            sub.w   #0x01, R15              ; Is current state at 3 ?
            jeq     rArrow3                 ; Yes, jump to state 3
            jmp     rArrow4                 ; Current state is at 4 (end)
rArrow0:    and.b   #0x0F, &LCDM9           ; Clear all arrow segments
            bis.b   #BIT4, &LCDM9           ; Set the first arrow segment
            jmp     rArrow5                 ; Jump to inc arrow state counter
rArrow1:    and.b   #0x0F, &LCDM9           ; Clear all arrow segments
            bis.b   #BIT5, &LCDM9           ; Set the second arrow segment
            jmp     rArrow5                 ; Jump to inc arrow state counter
rArrow2:    and.b   #0x0F, &LCDM9           ; Clear all arrow segments
            bis.b   #BIT6, &LCDM9           ; Set the third arrow segment
            jmp     rArrow5                 ; Jump to inc arrow state counter
rArrow3:    and.b   #0x0F, &LCDM9           ; Clear all arrow segments
            bis.b   #BIT7, &LCDM9           ; Set the fourth arrow segment
            jmp     rArrow5                 ; Jump to inc arrowState counter
rArrow4:    mov.w   #0x00, &arrowState      ; Reset arrowState counter
rArrow5:    add.w   #0x01, &arrowState      ; Increment arrowState counter
            cmp.w   #0x04, &arrowState      ; Is (arrowState >= 4) ?
            jl      rArrow6                 ; Go to done if at end of state seq
            mov.w   #0x00, &arrowState      ; Reset arrowState counter
rArrow6:    ret                             ; Return from subroutine

;************************** GENERAL SYSTEM FUNCTIONS **************************

setStatLED: mov.b   R12, R14                ; Set LED based on system status
            sub.B   #0x00, R14              ; Check if status is zero
            jeq     setLED0                 ; Turn the LED ON
            sub.B   #0x01, R14              ; Decrement counter
            jne     setLED1                 ; Goto done
            mov.b   #ACTIVITY, &status      ; Blink (toggle) the LED
            xor.b   #ACTIVITY, &P1OUT       ; Physically toggle the LED pin
            ret                             ; Return from subroutine
setLED0:    mov.b   #0x00, &status          ; Turn LED ON
            bic.b   #ACTIVITY, &P1OUT       ; Physically clear the LED pin
setLED1:    ret                             ; Return from subroutine

;------------------------------------------------------------------------------
                                            ; Translate pulse count totals into
                                            ; corresponding actual RPMs
updateTach: mov.w   &tachCount, R12         ; Get the tachometer value
            rra.w   R12                     ; Divide by 2
            mov.w   #60, &IROP1             ; Multiply by 60 to get RPM
            mov.w   R12, &IROP2L            ; Load the main factor
            call    #UMPY_16x16             ; Call the 16-bit multiply function
            mov.w   &IROP2L, &tachRPM       ; Store the result into RAM
            mov.w   #0x00, &tachCount       ; Reset the pulse counter
            ret                             ; Return from subroutine

;************************* INTERRUPT SERVICE ROUTINES *************************

ISR_PORT2:  bit.b   #TACH, &P2IFG           ; Tachometer pulse detected ?
            jnc     ISR_P2D                 ; No, goto done
            add.w   #0x01, &tachCount       ; Yes, increment pulse counter
            bic.b   #TACH, &P2IFG           ; Clear PORT2 interrupt flag
ISR_P2D:    reti                            ; Return from interupt

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

ISR_TIMER0_A1:
            bic.w   #LPM0, 0x0(SP)          ; Clear LPM0
            bic.w   #TAIFG, &TA0CCTL1       ; Clear TA0CCR1 interrupt flag
            reti                            ; Return from interrupt

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

ISR_BT:     call    #toggleAnt              ; Blink the antenna icon on LCD
            reti                            ; Return from interrupt

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

ISR_WDT:    bic.w   #LPM0, 0x0(SP)          ; Clear LPM0
            reti                            ; Return from interrupt


;-------------------------------------------------------------------------------
; Interrupt Vectors Used for MSP430F41x
;-------------------------------------------------------------------------------

            .sect   ".int00"                ; Basic Timer Interrupt Vector loc
            .short  ISR_BT                  ; Basic Timer Interrupt Vector value

            .sect   ".int01"                ; Port 2 Interrupt Vector location
            .short  ISR_PORT2               ; Port 2 Interrupt Vector value

            .sect   ".int05"                ; Timer_A3 CCR1-CCR2 Int Vector loc
            .short  ISR_TIMER0_A1           ; Timer_A3 CCR1-CCR2 Int Vector val
	
            .sect   ".int10"                ; Watchdog Timer Int Vector location
            .short  ISR_WDT                 ; Watchdog Timer Int Vector value

            .sect   ".reset"                ; Main RESET Int Vector location
            .short  RESET                   ; Main RESET Int Vector value

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

            .end                            ; End of assembly source code

⌨️ 快捷键说明

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