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

📄 source2.txt

📁 c8051f020的lcd显示 可以直接应用 lcd是12864,驱动器ks0108
💻 TXT
字号:
#include <c8051f020.inc>                    // SFR declarations


ClkAtt7022  bit  p0.2
DsiAtt7022  bit  p0.3
DsoAtt7022  bit  p0.4
Csatt7022   bit  p0.5 
      org        0000h
      mov        oscxcn,#67h
ok:   mov        a,oscxcn
      jnb        acc.7,ok     //晶振初始化//
    
      mov        oscicn,#0dh  //使用外部晶振//

      mov        xbr0,#04h
      mov        xbr1,#00h
      mov        xbr2,#40h    
      mov        p0mdout,#2ch //端口初始化//
 
      mov        pcon,#00h
      mov        scon0,#50h
      mov        tmod,#20h
      mov        th1,#0fah
      mov        tl1,#0fah
      setb       tr1          //串口初始化//
     
		  
			
      mov        a ,#0d3h
			lcall      send_att7022_1byte
        
  du:  clr       p2.5
	     mov       a,#3eh
			 call       delay
			 call       delay
			 call       delay
			 call       delay
			 call       delay
      lcall      read_3byte
       

      mov        a,20h
      mov        sbuf0,a
      jnb        ti,$
      clr        ti
      call       delay
      mov        r7,#255
     djnz       r7,$
      nop
			nop
		   setb      p2.5
      ajmp       du
;===读3个字节 →  r2,r3,r4==
read_3byte:
      setb    CsAtt7022
      clr     ClkAtt7022
      clr     CsAtt7022
      nop
      nop
      call    send_att7022_1byte
      clr     a
	  	call       delay
			call       delay
			call       delay
			call       delay
			call       delay
			call       delay
			call       delay
      call    read_att7022_1byte
      mov     20h,a
			
      call    read_att7022_1byte
      mov     21h,a
			
      call    read_att7022_1byte
      mov    22h,a
      setb    ClkAtt7022
      setb    CsAtt7022
          ret
//从att7022读出一个字节数据//
read_att7022_1byte:
       mov    r3,#8    ;从att7026读出一字节数据
BIN1:
       setb   ClkAtt7022
       mov    r0,#255
			 djnz   r0,$

       mov    c,DsoAtt7022 
       rlc    a
       mov    r0,#255
			 djnz   r0,$
			 nop
			 nop
			 nop
			 nop

       clr    ClkAtt7022
       nop
        mov    r0,#255
			 djnz   r0,$
			 nop
			 nop
			 nop
			 nop

       djnz   r3,BIN1

           ret

;=========att7026写1个字节子程序============
send_att7022_1byte:

       mov    r0,#8    ;向att7026写入一字节数据
BOUT1:
       setb   ClkAtt7022
       rlc    A
       nop
       nop
       mov   DsiAtt7022,c
       nop
       nop
       clr   ClkAtt7022
       nop
       nop
       djnz   r0,BOUT1
      

			
           RET

	delay:  mov r4,#20
  d2 :  mov r5,#248
        djnz r5,$
        djnz r4,d2
        ret

⌨️ 快捷键说明

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