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

📄 fet440_lcd05.s43

📁 msp430f440的头程序
💻 S43
📖 第 1 页 / 共 2 页
字号:
#include    "msp430x44x.h" ;  MSP430x44x Standard Definitions
;*******************************************************************************
;  MSP-FET430P440 Demo - LCD, displays a real time clock on a static LCD
;
;  Description "FET440_RTCwLCD": This program maintains a real time clock and
;  displays the current time on a 3.5 digit static LCD. The colon between the 
;  minutes and seconds toggles on or off each second to indicate that the clock
;  is running.  The digits of the display are only rewritten each minute once
;  the elapsed seconds roll over from 60 back to 0. The fourth digit is 
;  automatically blanked for hours 1-9. The software is totally interrupt 
;  driven. It only comes out of low power mode 3 and executes code when a Basic
;  Timer interrupt occurs, once each second.
;
;  
;                                 Connections MSP430 -> LCD
;                                 -------------------------
;
;                                T.I.               Varitronix  
;                           MSP430x4xx MCU     3.5 digit, static LCD
;                                                 # VI-302-DP-S
;                           ---------------       --------------
;                          |          COM0 |-----|1,40 COM      |
;                          |          SEG0 |-----|21            |
;                          |          SEG1 |-----|20            |
;                          |          SEG2 |-----|19            |
;                          |          SEG3 |-----|18            |  
;                          |          SEG4 |-----|17            |
;                          |          SEG5 |-----|22            |
;                          |          SEG6 |-----|23            |
;                          |          SEG7 |-----|38 (low batt) |
;                          |          SEG8 |-----|25            | 
;                          |          SEG9 |-----|24            |
;                          |          SEG10|-----|15            |
;                          |          SEG11|-----|14            |
;                          |          SEG12|-----|13            | 
;                          |          SEG13|-----|26            |
;                          |          SEG14|-----|27            |
;                          |          SEG15|-----|28 (L)  COLON |
;                          |          SEG16|-----|30            | 
;                          |          SEG17|-----|29            |
;                          |          SEG18|-----|11            |
;                          |          SEG19|-----|10            |
;                       ---|R03       SEG20|-----|9             | 
;                      |   |          SEG21|-----|31            |
;                      |   |          SEG22|-----|32            |
;                     \|/  |          SEG23|-----|3 (B-C) =     |
;                     GND  |               |     | .5 digit ="1"|
;                           ---------------       --------------  
;
;                 NOTE: Pin R03 on the MSP430 must be connected to GND
;
;  B. Merritt
;  Texas Instruments Inc.
;  January 2002
;
;--------CPU register used------------------------------------------------------
;;;;;;;       R13, R14, R15                    ;used as temporary registers, can
                                               ;be reused 
                                               
;--------RAM bytes used for variables-------------------------------------------                                                
SEC           equ    0200h                     ;byte for counting seconds
MIN           equ    0201h                     ;byte for counting minutes
HOUR          equ    0202h                     ;byte for counting hours
COLON         equ    0203h                     ;temporary storage to flash colon

;--------RAM words used for variables------------------------------------------- 
LCDTEMP       equ    0204h                     ;temporary storage in LCD routine

;-------------------------------------------------------------------------------
              ORG    0E000h                    ;Program reset
;-------------------------------------------------------------------------------
RESET         mov    #300h,SP                  ;itialize stackpointer          
              call   #Setup                    ;configure MSP430 for application
              
Mainloop      bis    #LPM3,SR                  ;set SR bits to wait in LPM3

;------------------------------------------------------------------------------- 
;             Increment clock values every second 
;-------------------------------------------------------------------------------
Clock         setc                             ;entry every second
              dadc.b SEC                       ;increment seconds, add carry bit
              cmp.b  #060h,SEC                 ;one minute elapsed?
              jlo    End_CLK                   ;no, (C = 0) w/o LCD update
              clr.b  SEC                       ;yes, clear seconds (C = 1)
Clock1        dadc.b MIN                       ;increment minutes if set carry
              cmp.b  #060h,MIN                 ;sixty minutes elapsed?
              jlo    Dis_Clock                 ;no, jump to update time display
              clr.b  MIN                       ;yes, clear minutes
              dadc.b HOUR                      ;increment hour
              cmp.b  #013h,HOUR		       ;12 hours elapsed?	 
              jlo    Dis_Clock                 ;no, jump to update time display
              mov.b  #01h,HOUR                 ;yes, set hours back to 1 &
                                               ;fall through to display time
                                               
;-------------------------------------------------------------------------------
;             Display clock values contained in RAM Bytes MIN & HOUR. 
;             CPU Registers R15 and R13 used temporarily.
;-------------------------------------------------------------------------------
Dis_Clock     mov.b  #LCDM1,R15;               ;R15 points to first LCD location
              mov.b  MIN,R14                   ;minute BCD value to R14
              call   #Pass_Bytes               ;call routine to display minutes
              mov.b  HOUR,R14                  ;hour BCD value to R14
              call   #Pass_Bytes               ;call routine to display hours
End_CLK       ret                              ;return to Basic Timer ISR

Pass_Bytes    mov.b  R14,R13                   ;copy R14 to R13, so R14 saved
              call   #ToLCD                    ;call to display 1st digit
              mov.b  R14,R13                   ;recopy R14 to R13, so R14 saved
              rra.b  R13                       ;right shift R13 4 times to 
              rra.b  R13                       ;move 2nd nibble to lower 4 bits
              rra.b  R13                       ;
              rra.b  R13                       ;
              call   #ToLCD                    ;call to display 2nd digit
              ret                              ;return to Dis_Clock routine
               
;-------------------------------------------------------------------------------
;             Display 1 digit on static LCD. CPU Registers R15, R14 and R13
;             used temporarily
;-------------------------------------------------------------------------------

⌨️ 快捷键说明

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