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

📄 source2.c

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

tx  bit p0.0
rx  bit p0.1
ClkAtt7022  bit  p0.2
DsiAtt7022   bit  p0.3
DsoAtt7022  bit  p0.4
 Csatt7022   bit  p3.7           
ad1   data  20h
ad2   data  21h
ad3   data  22h


org  0000h

//
kaishi: mov  p2mdout,#00h   
mov  xbr2,#40h
//晶振初始化选择//
mov  oscxcn,#67h
ok: mov   a,oscxcn
    jnb   acc.7,ok
     mov  p2,#0ffh

     mov  oscicn,#0dh  ;使用外部时钟

     mov  p0mdout,#0ffh  ;端口配置,P0.0 P0.3设置为推挽
		 mov  p2mdout,#00h
		 mov  p3mdout,#0ffh
		 mov  p74out,#0ffh
		
		 mov  xbr0,#04h    ;uart,spi使能
		 mov  xbr1,#00h
     mov  xbr2,#40h

		  mov pcon,#00h
     mov  scon0,#50h
     mov  tmod,#20h
     mov  th1,#0fah
		 mov  tl1,#0fah
		 setb tr1
   
     mov p2,#40h
    

mov  p0mdout,#0dh  ;端口配置,P0.0 P0.3设置为推挽
     
      



		   mov    a,#0d3h
			 setb    CsAtt7022
       clr     ClkAtt7022
       clr     CsAtt7022
       nop
       nop
       call    send_att7022_1byte
			 nop
			 nop
       setb    ClkAtt7022
       setb    CsAtt7022
       mov  r6,#50

	 dengdai:   lcall   delay
      djnz   r6,dengdai
	 mov   a,#3eh
		      lcall   read_3byte
	loop:				 mov   a,50h


        mov  sbuf0,a
			
		 jnb ti,$
			clr ti
     
			lcall  delay
			lcall  delay
			lcall  delay
			lcall  delay
			lcall  delay
			lcall  delay
			mov    r7,#50
	yanshi:		lcall  delay
			djnz   r7,yanshi
		;	mov  sbuf0,55h
		 ;jnb   ti,$
		;	clr   ti
			 
			lcall  delay
			lcall  delay
			lcall  delay
			lcall  delay
			lcall  delay
			lcall  delay
			mov    r7,#50
	yan:		lcall  delay
			djnz   r7,yan
			 ajmp   loop


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



read_3byte:
      setb    CsAtt7022
      clr     ClkAtt7022
      clr     CsAtt7022
      nop
      nop
      call    send_att7022_1byte
      clr     a
      call    read_att7022_1byte
      mov        50h,a
      
      call    read_att7022_1byte
      mov        51h,a
      
      call    read_att7022_1byte
			mov        52h,a
      setb    ClkAtt7022
      setb    CsAtt7022
          ret


read_att7022_1byte:
       mov    r3,#8    ;从att7026读出一字节数据
BIN1:
       setb   ClkAtt7022
       nop
       nop
       mov    c,DsoAtt7022
       rlc    a
       nop
       nop
       clr    ClkAtt7022
       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


⌨️ 快捷键说明

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