sys_driver.asm

来自「PCM 脉冲编码调制的C源代码」· 汇编 代码 · 共 646 行

ASM
646
字号
    .asg #17f1h,DATA_LCD	;lcd addr is 0x1af0 + 0x200000 (in CE1)
	.asg #17f0h, CMD_LCD	;lcd rst addr(cpld_ctrl_reg) is 0x0ef0 + 0x200000 (in CE1)
	
	.def delay_				;0x201af0
	.def delay_us

	.def _initial_lcd
	.def _off_lcd
	.def _on_lcd

;-------------------------------------------------	
_initial_lcd:
	push(ar5)
	bit(st1,#11)=#1 ;disable all the interrupt. 
	xar0=#200000h
	
	;command reset registers. 
	ar0=CMD_LCD
	*ar0=#0301h
		repeat(#8)
		nop_16
	*ar0=#2201h
		repeat(#8)
		nop_16
	
	ar5=#250
	call delay_us
	
	;gate output
	ar0=CMD_LCD
	*ar0=#6100h
		repeat(#8)
		nop_16
	*ar0=#6209h
		repeat(#8)
		nop_16
	*ar0=#6334h
		repeat(#8)
		nop_16
	*ar0=#6430h
		repeat(#8)
		nop_16
	*ar0=#6600h
		repeat(#8)
		nop_16
	*ar0=#6709h
		repeat(#8)
		nop_16
	*ar0=#6806h
		repeat(#8)
		nop_16
	*ar0=#6924h
		repeat(#8)
		nop_16
		
	;the same as before.
	*ar0=#0d01h
		repeat(#8)
		nop_16
	*ar0=#2800h
		repeat(#8)
		nop_16
	*ar0=#2900h
		repeat(#8)
		nop_16
	*ar0=#5040h
		repeat(#8)
		nop_16
	*ar0=#5237h
		repeat(#8)
		nop_16
	*ar0=#5300h
		repeat(#8)
		nop_16
	*ar0=#5400h
		repeat(#8)
		nop_16
	 *ar0=#720ah
	;*ar0=#7212h
		repeat(#8)
		nop_16
	;*ar0=#7920h
		;repeat(#8)
		;nop_16
	*ar0=#2d01h
		repeat(#8)
		nop_16
	
	ar5=#76
	call delay_us
	
;this is the write data routie set modle. 
	ar0=CMD_LCD
	*ar0=#2d00h
		repeat(#8)
		nop_16
	*ar0=#09afh
		repeat(#8)
		nop_16
	*ar0=#0800h
		repeat(#8)
		nop_16
	*ar0=#0bdbh
		repeat(#8)
		nop_16
	*ar0=#0a00h
		repeat(#8)
		nop_16
		;ar5=#250
		;call delay_
		
	;*ar0=#0510h ;wsa mode.
	*ar0=#0540h  ;bstr mode, high speed mean full scree display.
		repeat(#8)
		nop_16
	*ar0=#0600h
		repeat(#8)
		nop_16
	*ar0=#0700h
		repeat(#8)
		nop_16
		
		;ar5=#250
		;call delay_
		
	ar0=DATA_LCD
	t0=#220 ;ar2
	t1=#176 ;ar3
row_loop:
	t1=#176 ;ar3
column_loop:	
	*ar0=#001fh ;white color.
	t1-=#1
	if(t1!=#0) goto column_loop
	t0-=#1
	if(t0!=#0) goto row_loop
	xar0=#200000h
	ar0=CMD_LCD
	*ar0=#1916h
		repeat(#8)
		nop_16
			ar5=#250
			call delay_us
	*ar0=#1a25h
		repeat(#8)
		nop_16
			ar5=#250
			call delay_us
	*ar0=#1b6ah
		repeat(#8)
		nop_16
			ar5=#250
			call delay_us
	*ar0=#1c00h
		repeat(#8)
		nop_16
			ar5=#250
			call delay_us
	*ar0=#1d07h
		repeat(#8)
		nop_16
			ar5=#250
			call delay_us
	*ar0=#1e03h
		repeat(#8)
		nop_16
			ar5=#250
			call delay_us	
	*ar0=#1f00h
		repeat(#8)
		nop_16
			ar5=#250
			call delay_us		
	*ar0=#2000h
		repeat(#8)
		nop_16
			ar5=#250
			call delay_us		
	*ar0=#212fh
		repeat(#8)
		nop_16
			ar5=#250
			call delay_us		
	*ar0=#185eh
		repeat(#8)
		nop_16
			ar5=#250
			call delay_us		
	*ar0=#1b6bh
		repeat(#8)
		nop_16
			ar5=#250
			call delay_us		
	*ar0=#185fh
		repeat(#8)
		nop_16
			ar5=#200
			call delay_		
	*ar0=#3701h
		repeat(#8)
		nop_16		
	*ar0=#3b01h
		repeat(#8)
		nop_16	
			ar5=#17
			call delay_
	*ar0=#0020h
		repeat(#8)
		nop_16
			ar5=#250
			call delay_us	
	
	bit(st1,#11)=#0 ;eanble the intrrupt.
	ar5=pop()
	return	
		
_on_lcd:;not used in this prj
	push(ar5)
	bit(st1,#11)=#1
	xar0=#200000h
	
	;command reset registers. 
	ar0=CMD_LCD
	*ar0=#0301h
		repeat(#8)
		nop_16
	*ar0=#2201h
		repeat(#8)
		nop_16
	
	ar5=#250
	call delay_us
	
	;gate output
	ar0=CMD_LCD
	*ar0=#6100h
		repeat(#8)
		nop_16
	*ar0=#6209h
		repeat(#8)
		nop_16
	*ar0=#6334h
		repeat(#8)
		nop_16
	*ar0=#6430h
		repeat(#8)
		nop_16
	*ar0=#6600h
		repeat(#8)
		nop_16
	*ar0=#6709h
		repeat(#8)
		nop_16
	*ar0=#6806h
		repeat(#8)
		nop_16
	*ar0=#6924h
		repeat(#8)
		nop_16
		
	;the same as before.
	*ar0=#0d01h
		repeat(#8)
		nop_16
	*ar0=#2800h
		repeat(#8)
		nop_16
	*ar0=#2900h
		repeat(#8)
		nop_16
	*ar0=#5040h
		repeat(#8)
		nop_16
	*ar0=#5237h
		repeat(#8)
		nop_16
	*ar0=#5300h
		repeat(#8)
		nop_16
	*ar0=#5400h
		repeat(#8)
		nop_16
	 *ar0=#720ah
	;*ar0=#7212h
		repeat(#8)
		nop_16
	;*ar0=#7920h
		;repeat(#8)
		;nop_16
	*ar0=#2d01h
		repeat(#8)
		nop_16
	
	ar5=#76
	call delay_us
	
;this is the write data routie set modle. 
	ar0=CMD_LCD
	*ar0=#2d00h
		repeat(#8)
		nop_16
	*ar0=#09afh
		repeat(#8)
		nop_16
	*ar0=#0800h
		repeat(#8)
		nop_16
	*ar0=#0bdbh
		repeat(#8)
		nop_16
	*ar0=#0a00h
		repeat(#8)
		nop_16
		;ar5=#250 in fact, no this delay, can also work properly
		;call delay_
		
	;*ar0=#0510h
	*ar0=#0540h
		repeat(#8)
		nop_16
	*ar0=#0600h
		repeat(#8)
		nop_16
	*ar0=#0700h
		repeat(#8)
		nop_16
		
	ar0=DATA_LCD
	ar6=#220
	ar7=#176
row_loop_offToOn:
column_loop_offToOn:	
	*ar0=#0f000h
	ar7-=#1
	if(ar7!=#0) goto column_loop_offToOn
	ar6-=#1
	if(ar6!=#0) goto row_loop_offToOn
	xar0=#200000h
	ar0=CMD_LCD
	*ar0=#1916h
		repeat(#8)
		nop_16
			ar5=#250
			call delay_us
	*ar0=#1a25h
		repeat(#8)
		nop_16
			ar5=#250
			call delay_us
	*ar0=#1b6ah
		repeat(#8)
		nop_16
			ar5=#250
			call delay_us
	*ar0=#1c00h
		repeat(#8)
		nop_16
			ar5=#250
			call delay_us
	*ar0=#1d07h
		repeat(#8)
		nop_16
			ar5=#250
			call delay_us
	*ar0=#1e03h
		repeat(#8)
		nop_16
			ar5=#250
			call delay_us	
	*ar0=#1f00h
		repeat(#8)
		nop_16
			ar5=#250
			call delay_us		
	*ar0=#2000h
		repeat(#8)
		nop_16
			ar5=#250
			call delay_us		
	*ar0=#212fh
		repeat(#8)
		nop_16
			ar5=#250
			call delay_us		
	*ar0=#185eh
		repeat(#8)
		nop_16
			ar5=#250
			call delay_us		
	*ar0=#1b6bh
		repeat(#8)
		nop_16
			ar5=#250
			call delay_us		
	*ar0=#185fh
		repeat(#8)
		nop_16
			ar5=#200
			call delay_		
	*ar0=#3701h
		repeat(#8)
		nop_16		
	*ar0=#3b01h
		repeat(#8)
		nop_16	
			ar5=#17
			call delay_
	*ar0=#0020h
		repeat(#8)
		nop_16
			ar5=#250
			call delay_us	
	bit(st1,#11)=#0
	ar5=pop()
	return
	;this is the power routie. 
	
_off_lcd:
	push(ar5)
	bit(st1,#11)=#1
	xar2=#200000h
	ar2=CMD_LCD
	*ar2=#00a0h
	ar5=#17
	call delay_
	*ar2=#00a8h
	ar5=#17
	call delay_
	*ar2=#185eh
	ar5=#250
	call delay_us
	*ar2=#0101h
	bit(st1,#11)=#0		;enable
	ar5=pop()
	return
;;=================================================================
 
   
;--------------------------------------------   
   .global _scroll
   .text
_scroll:
      pshboth(xar2)
      nop
      nop
      nop
      xar2=#200000h
      ar2=CMD_LCD
      ;*ar2=#0020h
      ;*ar2=#0100h
      ;*ar2=#0f40h
      ;*ar2=#1020h
cycle:
      *ar2=#1110h
      *ar2=#0600h      
      *ar2=#0750h 
 
      xar2=popboth()
      return
            
;--------------------------------------------
   .global _mode_scroll
   .text
_mode_scroll:
      pshboth(xar2)
      nop
      nop
      nop
      xar2=#200000h
      ar2=CMD_LCD
      *ar2=#0020h
      *ar2=#0100h
      *ar2=#0f40h
      *ar2=#1040h
cycle_scroll:
      *ar2=#1110h
      *ar2=#0600h      
      *ar2=#0750h 
end1:
      xar2=popboth()
      return
           
;-------------------------------------------- 
      .global _wave_data
      .text
_wave_data:
      ;pshboth(xar1)
      brc0=#175
      localrepeat{
                  ac2=*ar0
                  ar0=ar0+#2
                  ac2=ac2<<#-3
                  *ar1=ac2
                  ar1=ar1+#1 
                  nop_16
                 }  
      return
        
;--------------------------------------------
    .global _mode_draw_wave
    
    .text
_mode_draw_wave: 
    push(ar4)
    xar0=#200000h
    ar0=CMD_LCD
    
    *ar0=#0000h;adc
    *ar0=#01c0h;adx,adr
    ar4=t0
    ar2=t1
    ar3=#09afh
    *ar0=ar3    
    ar3=#0800h+ar4
    *ar0=ar3
    ar3=#0b7fh+ar2
    *ar0=ar3
    ar3=#0a00h+ar2
    *ar0=ar3
    
    *ar0=#0514h
    
    ar3=#0600h+ar4
    *ar0=ar3
    ar3=#0700h+ar2
    *ar0=ar3
    ar4=pop()
    return 
    
;--------------------------------------------
   .global _mode_partial
_mode_partial
  .text
  pshboth(xar0)
  nop
  nop
  nop
  xar0=#200000h
  ar0=CMD_LCD
  *ar2=#0020h;h->L
  *ar0=#0080h
  *ar0=#1302h;r19
  ;display data overwrite
  *ar0=#1400h;r20,partial 1   R
  ;*ar0=#1550h;r21
  *ar0=#1640h;r22
  ;*ar0=#1740h;r23
  *ar0=#0094h
  *ar0=#0014h
  xar0=popboth()
  return
		 
;--------------------------------------------		 
          .mmregs
;char_addr .long 0x621000  ;address of rom
          .global _char_read_1
  .text
_char_read_1:
     ;cpl=#0h
     .cpl_off
     pshboth(xar3)
     nop
     nop
     nop
     ;ar2=char_addr
     ;ac1=*ar2
     ;ac1=ac1<<#16
;     xar2=#621h
     ;xar2=#0bh
     xar2 = #1380h
     ac1=xar2
     ;ac1=ac1<<<#12
     ac0=ac0+ac1
     xar3=ac0
     brc0=#0fh
     localrepeat{
                ac1=*ar3
                ar3+=#01h
                *ar0=ac1
                ar0+=#01h
                }
     .cpl_on
     xar3=popboth()
     return
  
  
  
;--------------------------------------------
	.global _char_mode_window
_char_mode_window:	
	.text
    xar0=#200000h
	ar0=CMD_LCD
	ar4=t0
	ar5=t1
	;ar4=#090fh+ar4
	;*ar0=ar4
	*ar0=#0020h
	*ar0=#0100h
	ar3=#0907h+ar4
	*ar0=ar3
	ar3=#0800h+ar4
	*ar0=ar3
	ar3=#0b0fh+ar5
	*ar0=ar3
	ar3=#0a00h+ar5
	*ar0=ar3
	*ar0=#0550h
	ar3=#0600h+ar4
	*ar0=ar3
	ar3=#0700h+ar5
	*ar0=ar3
	return
	

;------------------------------------------------------	
delay_:
	pshboth(ac2)
test_circle2_delay_sub:	
	;inner circle
	ac2=#3fffh
test_circle_delay_sub:
	ac2-=#1
	nop
	if (ac2!=#0) goto test_circle_delay_sub
	;outer circle
	ar5-=#1 ;decrement the ar5
	if(ar5!=#0) goto test_circle2_delay_sub
	ac2=popboth()
	return
delay_us:
	pshboth(ac2)
test_circle2_delay_us_sub:	
	;inner circle
	ac2=#0fh
test_circle_delay_us_sub:
	ac2-=#1
	nop
	if (ac2!=#0) goto test_circle_delay_us_sub
	
	;outer circle
	ar5-=#1 ;decrement the ar5
	if(ar5!=#0) goto test_circle2_delay_us_sub
	ac2=popboth()
	return

⌨️ 快捷键说明

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