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

📄 main.asm

📁 ST7 Software LCD driver
💻 ASM
字号:
st7/

;************************************************************************ 
; TITLE:                MAIN.ASM
; DESCRIPTION:          Software LCD driver - User Main program
; COMMENTS:             You can directly add your program here. This example
;                       initializes the variables with the values, according to 
;                       the characters to be displayed on the LCD. Values completely
;			depends up on the LCD type used.   
; Version:		Ver 1.0
;************************************************************************

        TITLE    "MAIN.ASM"           
        MOTOROLA
        
        #INCLUDE "st72321.inc"          ; include st72321 registers and memory mapping file
        #INCLUDE "variable.inc"         ; include general constants file
        
;***********************************************************************
;       Variables, constants defined and referenced locally
;       You can define your own values for a local reference here
;***********************************************************************

;************************************************************************
;       Public routines  (defined here)
;************************************************************************
; routines

;************************************************************************
;       Extern routines   (defined elsewhere)
;
;       The EXTERN directive will be seen by the linker as a call
;       instruction to another routine written in another file
;************************************************************************
                EXTERN tima_rt.w       ; timer A interrupt written in lcd.asm
                EXTERN port_init.w   
                EXTERN timer_config.w

;**********************************************************
; Program code                                        
; LCD used contains 36-pins with 32 segment pins and 4 COM pins.
; So, it contains total 32x4 =128 segments.
; LCD contains 8 star-type characters each having 16-segments EACH SO (16 X 8=128)
; One LCD chracter is shown below:
;              A
;      --  ----------
;    X \/  |\H  |I  /|
;         F| \  | J/ |B
;          | G\ | /K |
;          ----- -----
;          |   /| \  |
;        E | L/ |M \N|C
;          | /  |   \|   _
;          -----------  | |DP   
;              D         -

; Following are connections from the MCU to the LCD
;----------------------------------------------
; LCD Pin No   |   Segment    |   Micro Port |
;----------------------------------------------
;  1           |9X,8F,8E,8D   |     PD6      |
;  2           |8I,8J,8K,8N   |     PD4      |
;  3           |8X,7F,7E,7D   |     PD2      |
;  4           |7I,7J,7K,7N   |     PD0      |
;  5           |7X,6F,6E,6D   |     PB6      |
;  6           |6I,6J,6K,6N   |     PB4      |
;  7           |6X,5F,5E,5D   |     PB2      |
;  8           |5I,5J,5K,5N   |     PB0      |
;  9           |5X,4F,4E,4D   |     PF6      |
;  10          |4I,4J,4K,4N   |     PF4      |
;  11          |4X,3F,3E,3D   |     PF2      |
;  12          |3I,3J,3K,3N   |     PF0      |
;  13          |3X,2F,2E,2D   |     PE6      |
;  14          |2I,2J,2K,2N   |     PA4      |
;  15          |2X,1F,1E,1D   |     PA2      |
;  16          |1I,1J,1K,1N   |     PA0      |
;  17          |, , ,COM4     |     PC3      |
;  18          |, ,COM3,      |     PC2      |
;  19          |,COM2,,       |     PC1      |
;  20	       |COM1,,,       |     PC0      |
;  21          |1A,1B,1C,1DP  |     PA1      |
;  22          |1H,1G,1L,1M   |     PA3      |
;  23          |2A,2B,2C,2DP  |     PA5      |
;  24          |2H,2G,2C,2DP  |     PE7      |
;  25          |3A,3B,3C,3DP  |     PF1      |
;  26          |3H,3G,3L,3M   |     PF3      |
;  27          |4A,4B,4C,4DP  |     PF5      |
;  28          |4H,4G,4L,4M   |     PF7      |
;  29          |5A,5B,5C,5DP  |     PB1      |
;  30          |5H,5G,5C,5DP  |     PB3      |
;  31          |6A,6B,6C,6DP  |     PB5      |
;  32          |6H,6G,6L,6M   |     PB7      |
;  33          |7A,7B,7C,7DP  |     PD1      |
;  34          |7H,7G,7C,7DP  |     PD3      |
;  35          |8A,8B,8C,8DP  |     PD5      |
;  36          |8H,8G,8L,8M   |     PD7      |

;**************************************************

        WORDS

    segment 'rom'

.main
                CALL port_init
                LD Y,#$01
                LD segB4,Y  ; SegB4 is loaded with the values for the segments which are externally connected to PORTB on one side & connected internally to COM4 on the other side
                LD Y,#$16
                LD segB3,y  ; SegB3 is loaded with the values for the segments which are externally connected to PORTB on one side & connected internally to COM3 on the other side               
                LD Y,#$86
                LD segB2,Y  ; SegB2 is loaded with the values for the segments which are externally connected to PORTB on one side & connected internally to COM2 on the other side                       
                LD Y,#08
                LD segB1,Y  ; SegB1 is loaded with the values for the segments which are externally connected to PORTB on one side & connected internally to COM1 on the other side                 
                LD Y,#$40
                LD segA4,Y
                LD Y,#$67
                LD segA3,Y
                LD Y,#$6e
                LD segA2,Y
                LD Y,#$22
                LD segA1,Y 
                
                               
                LD Y,#$48 
                LD segD4,Y
                LD Y,#$30
                LD segD3,Y
                LD Y,#$c0
                LD segD2,Y
                LD Y,#$23
                LD segD1,Y  
                LD Y,#$48       
                LD segF4,Y
                LD Y,#$60       
                LD segF3,Y
                LD Y,#$60       
                LD segF2,Y
                LD Y,#$21       
                LD segF1,Y   
                
                LD Y,#$40
                LD segE4,Y
                LD Y,#$40
                LD segE3,Y
                LD Y,#$40
                LD segE2,Y
                LD Y,#$00
                LD segE1,Y 

                CALL timer_config
                RIM

while1          
wait
                LD Y,#$03
                LD cpt3,Y
wait3           LD Y,#$FF
                LD cpt2,Y
wait2           LD Y,#$FF
                LD cpt1,Y
wait1           DEC cpt1
                JRNE wait1
                DEC cpt2
                JRNE wait2
                DEC cpt3
                JRNE wait3

                JRT while1        

;       ********************************************
;       *                                          *
;       *  INTERRUPT SUB-ROUTINES LIBRARY SECTION  *
;       *                                          *
;       ********************************************

dummy1	iret 
dummy2  iret
dummy3  iret
dummy4  iret
dummy5  iret
dummy7  iret
dummy8  iret
dummy9  iret
dummy10 iret
dummy11 iret
dummy12 iret
dummy13 iret
dummy14 iret
dummy15 iret

;tima_rt interrupt written in lcd.ram file

       segment 'vectit'

; *******************************************************************
; This last segment should always be there in your own programs.
; It defines the interrupt vector adresses and the interrupt routines' labels
; considering the microcontroller you are using. 
; Refer to the MCU's datasheet to see the number of interrupt vector
; used and their addresses.
; Remind that this example is made for a ST72321 based application.
; *******************************************************************


; *******************************************************************
; Each interrupt vector uses two addresses in rom, that's what the directive
; DC.W means. It says "reserve a word location (.W) in rom (DC) and code
; the routine's label in those two addresses.
; Yet, when an interrupt occurs, for example from the timerB, timerb's routine
; address (tima_rt) will be loaded in the PC and the program will jump to this 
; label if allowed. It will execute this routine and then will go back to the main
; program (see interrupt chapter in the datasheet for a more precise description
; of how to handle interrupts in ST72 micros).
; ******************************************************************* 


                DC.W    dummy1           ;FFE0-FFE1h location 
                DC.W    dummy2           ;FFE2-FFE3h location
		DC.W    dummy3		;FFE4-FFE5h location  
                DC.W    dummy4           ;FFE6-FFE7h location  
                DC.W    dummy5		;FFE8-FFE9h location  
.tima_it	DC.W    tima_rt		;FFEA-FFEBh location  
		DC.W    dummy7		;FFEC-FFEDh location               
		DC.W    dummy8		;FFEE-FFEFh location
                DC.W    dummy9           ;FFF0-FFF1h location                 
	        DC.W    dummy10		;FFF2-FFF3h location                       
		DC.W    dummy11           ;FFF4-FFF5h location  
                DC.W    dummy12           ;FFF6-FFF7h location             
                DC.W    dummy13           ;FFF8-FFF9h location 
                DC.W    dummy14           ;FFFA-FFFBh location                      
                DC.W    dummy15           ;FFFC-FFFDh location                       
.reset          DC.W    main            ;FFFE-FFFFh location  

             ; This last line refers to the first line.
             ; It used by the compiler/linker to determine code zone
             
        
        END  ; Be aware of the fact that the END directive should not
             ; stand on the left of the page like the labels's names.
             
                     
             
             
             
             
             
             
             

⌨️ 快捷键说明

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