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

📄 lcd1.a30

📁 一个瑞萨单片机的程序。。。供大家学习用。。。。。。。。。。。。。。。。。。
💻 A30
📖 第 1 页 / 共 2 页
字号:
;                 : 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
;                 :     BSET:G  RS 50*3=187.5     1  .  .  .      | .    .
;                 :     MOV.B:S #W 50*2=125.0     .  .  .  WR     | .    OUT
;                 :     BSET:G  E  50*3=187.5     .  .  1  .      | .    .
;                 :     MOV.B:G    50*2=125.0     .  .  .  .      | .    .
;                 :     MOVLL      50*5=312.5     .  .  .  .      |(WR Data)
;                 :     BCLR:G  E  50*3=187.5     .  .  0  .      | .    .
;                 :     MOV.B:S #R 50*2=125.0     .  .  .  RD     | IN
; History         : ---
;""SUBR COMMENT END""**********************************************************
        .section        program         ; same section as the C program
        .glb            $_lcd1__wr_nibble_dreg
                                        ; global definition
$_lcd1__wr_nibble_dreg:
        ;---- select data ----
        bset:g  p1_6_RS                 ; select data
                                        ; (set RS port of LCD module as "H")

        ;---- 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 to input port
                                        ; (set P10 to P13 as input port)
        rts


;""SUBR COMMENT""**************************************************************
; ID              : ---
; subroutine name : int _lcd1__rd_nibble_creg(void)
; function        : read command register of LCD(SC1602BS*2)
; input           : none
; output          : int value have been read(only low 4 bits available)
; subroutine used : none
; stack           : 0 byte 
; notice          : because Write is fixed in OAKS8-LCDBoard, can not read
;                 : get return value from R0(return value 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=187.5     0  .  .  .      | .    .
;                 :     BSET:G  RW 50*3=187.5     .  1  .  .      | OUT  .
;                 :     BSET:G  E  50*3=187.5     .  .  1  .      | .    .
;                 :     NOP        50*1= 62.5     .  .  .  .      | .    .
;                 :     NOP        50*1= 62.5     .  .  .  .      | .    .
;                 :     NOP        50*1= 62.5     .  .  .  .      | .    .
;                 :     MOV.B:G    50*2=125.0     .  .  .  .      |(RD Command)
;                 :     AND.W:G    50*3=187.5     .  .  .  .      | .    .
;                 :     BCLR:G  E  50*3=187.5     .  .  0  .      | .    .
;                 :     BCLR:G  RW 50*3=187.5     .  0  .  .      | IN   .
; History         : ---
;""SUBR COMMENT END""**********************************************************
        .section        program         ; same section as the C program
        .glb            __lcd1__rd_nibble_creg
                                        ; global definition
__lcd1__rd_nibble_creg:
        ;---- select command ----
        bclr:g  p1_6_RS                 ; select command
                                        ; (set RS port of LCD module as "L")

        ;---- set as reading from LCD ----
        ;mov.b:s #R, pd1                ; set CPU port as input
        ;                               ; (set P10 to P13 as input port)
        ;bset:g  p1_x_RW                ; set LCD module as output
                                        ; (set RW of LCD as "H":READ)
                                        ; Write is fixed in OAKS8-LCDBoard
                                        ; comment out

        ;---- read 4 bits ----
        bset:g  p1_7_E                  ; set E port of LCD module as "H"
        nop                             ; fit timing
        nop                             ; fit timing
        mov.b:g p1, R0L                 ; set value read from LCD as return value (R0)
        and.w:g #0fH, R0                ; (R0 = p1&0x0f)
        bclr:g  p1_7_E                  ; set E port of LCD module as "L"

        ;---- set back port to initial status ----
        ;bclr:g  p1_x_RW                ; set back LCD module to input status
                                        ; (set as L:WRITE)
                                        ; Write is fixed in OAKS8-LCDBoard
                                        ; comment out
        rts


;""SUBR COMMENT""**************************************************************
; ID              : 
; subroutine name : int _lcd1__rd_nibble_dreg(void)
; function        : read data register of LCD(SC1602BS*2)
; input           : none
; output          : int value have been read(only low 4 bits available)
; subroutine used : none
; stack           : 0 byte 
; notice          : because Write is fixed in OAKS8-LCDBoard, can not read 
;                 : get return value from R0(return value 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
;                 :     BSET:G  RS 50*3=187.5     1  .  .  .      | .    .
;                 :     BSET:G  RW 50*3=187.5     .  1  .  .      | OUT  .
;                 :     BSET:G  E  50*3=187.5     .  .  1  .      | .    .
;                 :     NOP        50*1= 62.5     .  .  .  .      | .    .
;                 :     NOP        50*1= 62.5     .  .  .  .      | .    .
;                 :     MOV.B:G    50*2=125.0     .  .  .  .      |(RD Data)
;                 :     AND.W:G    50*3=187.5     .  .  .  .      | .    .
;                 :     BCLR:G  E  50*3=187.5     .  .  0  .      | .    .
;                 :     BCLR:G  RW 50*3=187.5     .  0  .  .      | IN   .
;; History         : ---
;""SUBR COMMENT END""**********************************************************
        .section        program         ; same section as the C program
        .glb    __lcd1__rd_nibble_dreg  ; global definition
__lcd1__rd_nibble_dreg:
        ;---- select data ----
        bset:g  p1_6_RS                 ; select data
                                        ; (set RS port of LCD module as "H")

        ;---- set as reading from LCD ----
        ;mov.b:s #R, pd1                ; set CPU port as input
        ;                               ; (set P10 to P13 as input port)
        ;bset:g  p1_x_RW                ; set LCD module as output 
                                        ; (set RW of LCD as "H":READ)
                                        ; Write is fixed in OAKS8-LCDBoard 
                                        ; comment out

        ;---- read 4 bits ----
        bset:g  p1_7_E                  ; set E port of LCD module as "H"
        nop                             ; fit timing
        nop                             ; fit timing
        nop                             ; fit timing
        mov.b:g p1, R0L                 ; set value read from LCD as return value (R0)
        and.w:g #0fH, R0                ; (R0 = p14&0x0f)
        bclr:g  p1_7_E                  ; set E port of LCD module as "L"

        ;---- set back port to initial status ----
        ;bclr:g  p1_x_RW                ; set back LCD module to input status
                                        ; (set as L:WRITE)
                                        ; Write is fixed in OAKS8-LCDBoard
                                        ; comment out
        rts


        .end
;******************************************************************************
;       end of file
;******************************************************************************

⌨️ 快捷键说明

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