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

📄 lcd1.a30

📁 一个瑞萨单片机的程序。。。供大家学习用。。。。。。。。。。。。。。。。。。
💻 A30
📖 第 1 页 / 共 2 页
字号:
;""FILE COMMENT""**************************************************************
;  System Name : for eduction (NO TRANSFERRING)
;  File Name   : lcd1.a30
;  Contents    : the low level program used by LCD(assembly language)
;  Model       : for OAKS8-LCD Board
;  CPU         : R8C/Tiny series
;  Assembler   : as30(V.5.10.00)
;  Linker      : ln30(V.5.10.0)
;  Programer   : RENESAS Semiconductor Training Center
;  Note        : for OAKS8-R5F21114FP(R8C/11 group,20MHz)
;              : for SC1602BS*B material
;******************************************************************************
; COPYRIGHT(C) 2004 RENESAS TECHNOLOGY CORPORATION
; AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED
;******************************************************************************
; History      : ---
;""FILE COMMENT END""**********************************************************

        .include        target.inc      ; for M16C/60 series
                                        ; SFR section definition file
;==============================================================================
;       define symbol
;==============================================================================
p1_6_RS         .btequ  p1_6            ; RS port (bit 6 of port P1)
                                        ; 0:command-reg, 1:data-reg
p1_7_E          .btequ  p1_7            ; E port (bit 7 of port P1)
                                        ; 1:strobe, falling edge:RW

R               .equ    11000000B       ; the value to set for LCD
                                        ; reading from LCD module to M16C
                                        ; input only (the low 4 bits(DATA port),
                                        ; MSB not be used)
W               .equ    11001111B       ; the value to set for LCD
                                        ; writing from M16C to LCD module
                                        ; (output all, MSB not be used)
DEF_P1_DATA     .equ    00000000B       ; when not to operate LCD
                                        ; port P1 register settings is as below
                                        ; 00000000
                                        ; ||||++++---- B3-0   = 0
                                        ; |||+-------- B4(E)  = L
                                        ; ||+--------- B5(RW) = L(WRITE)
                                        ; |+---------- B6(RS) = L(COMMAND)
                                        ; +----------- B7     = L(OPEN)

;""SUBR COMMENT""**************************************************************
; ID              : ---
; subroutine name : void _lcd1__initial(void)
; function        : LCD control port initialization
; input           : none
; output          : none
; subroutine used : none
; stack           : 0 byte
; notice          : only initialization, LCD can not display
; History         : ---
;""SUBR COMMENT END""**********************************************************
        .section        program         ; same section as the C program
        .glb            __lcd1__initial ; global definition
__lcd1__initial:
        mov.b   #DEF_P1_DATA, p1        ; set data bus as status not be used
        mov.b   #R, pd1      ; set reading from LCD module
                                        ; (set port P10-P13 as input port)
                                        ; (set port P14-P16 as output port)
__lcd1__initial_end:
        RTS                             ; 62.5ns*6


;""SUBR COMMENT""**************************************************************
; ID              : ---
; subroutine name : void _lcd1__wait(unsigned int t)
; function        : wait t*100us
; input           : unsigned int t: wait time (t * 50us)
; output          : none
; subroutine used : none
; stack           : 0 byte
; notice          : the firt argument t(counter to express how many times to count 
;                 : 100us) is transferred by R1 register (argument transfer rule)
;                 : make 50us software wait with loop wait_loop_10
;                 : make t*50us software wait with wait_loop
;                 : take more time to make calculate easily
;                 : 
;                 : meaning of the value 100(1 cycle = 50ns@20MHz)
;                 :     50000ns = 50 * (1+100*(3+7)-4)
;                 :                          |       | |  |
;                 :                          |       | |  +---no bifurcation
;                 :                          |       | +------ADJNZ
;                 :                          |       +--------NOP*3
;                 :                          +----------------MOV
; History         : ---
;""SUBR COMMENT END""**********************************************************
        .section        program         ; same as the C program
        .glb            $_lcd1__wait    ; global definition
$_lcd1__wait:

wait_loop:
        mov.b:s #100, R0L               ; 50ns*1
wait_loop_10:
        nop                             ; 50ns*1
        nop                             ; 50ns*1
        nop                             ; 50ns*1
        adjnz.b #-1, R0L, wait_loop_10  ; 50ns*7(when no bifurction -4)
        adjnz.w #-1, R1, wait_loop      ; 50ns*7(when no bifurction -4)

$_lcd1__wait_end:
        rts                             ; 50ns*6


;""SUBR COMMENT""**************************************************************
; ID              : ---
; subroutine name : void _lcd1__wr_nibble_creg(int command)
; function        : write the command to the LCD(SC1602BS*2) command register
; input           : int command: data to be written (only low 4 bit available)
; output          : none
; subroutine used : none
; stack           : 0 byte
; notice          : argument command(command to be written to LCD module)
;                 : is transferred by R1 register (argument transfer rule)
;                 : 
;                 : control the timing as below, there is rule for time
;                 :     --------------------------+--+--+--+-------+----+-----
;                 :                 TIME           RS RW E  I/O-DIR LCD  M16C
;                 :     --------------------------+--+--+--+-------+----+-----
;                 :                          def= x  0  0  RD     | IN   IN
;                 :     BCLR:G  RS 50*3=150       0  .  .  .      | .    .
;                 :     MOV.B:S #W 50*2=100       .  .  .  WR     | .    OUT
;                 :     BSET:G  E  50*3=150       .  .  1  .      | .    .
;                 :     MOV.B:G    50*2=100       .  .  .  .      | .    .
;                 :     MOVLL      50*5=250       .  .  .  .      |(WR Command)
;                 :     BCLR:G  E  50*3=150       .  .  0  .      | .    .
;                 :     MOV.B:S #R 50*2=100       .  .  .  RD     | IN
; History         : ---
;""SUBR COMMENT END""**********************************************************
        .section        program         ; same section as the C program
        .glb            $_lcd1__wr_nibble_creg  
                                        ; global definition
$_lcd1__wr_nibble_creg:
        ;---- select command ----
        bclr:g  p1_6_RS                 ; select command
                                        ; (set RS port of LCD module "L")

        ;---- set as writing to LCD ----
        ;bclr:g  p1_X_RW                ; set LCD module as input
        ;                               ; (set RW of LCD as "L":WRITE)
        mov.b:s #W, pd1                 ; set CPU as output
                                        ; (set P10 to P13 as output port)

        ;---- write 4 bits----
        bset:g  p1_7_E                  ; set E port of LCD module as "H"
        mov.b:g R1L, R0L                ; write argument (R1) to LCD
        movll   R0L, p1                 ; (P1 = R1L transfer low 4 bits)
        bclr:g  p1_7_E                  ; set E port of LCD module as "L"

        ;---- set back port to initial status ----
        mov.b:s #R, pd1                 ; set back P10 to P13 as input port
                                        ; (set P10 to P13 as input port)
        rts


;""SUBR COMMENT""**************************************************************
; ID              : ---
; subroutine name : void _lcd1__wr_nibble_dreg(int data)
; function        : write data to data register of LCD(SC1602BS*2)
; input           : int data: data to be written (only low 4 bits available)
; output          : none
; subroutine used : none
; stack           : 0 byte
; notice          : argument data(data to be written to LCD module)

⌨️ 快捷键说明

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