找回密码
 注册会员
更新自动建库工具PCB Footprint Expert 2024.04 Pro / Library Expert 破解版

ADS7846 PROGRAM INSTRUCTION

[复制链接]
admin 发表于 2012-9-2 20:12:43 | 显示全部楼层 |阅读模式

本文包含原理图、PCB、源代码、封装库、中英文PDF等资源

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本人成功test到7846用8051仿真器,唔知有冇高手帮忙把它换成pic的呢?
p.s. pic instruction看过都不太明

$mod51

;connecting to uP
DCLK equ P1.7 ;clock
CS equ P1.6 ;low active enable
DIN equ P1.5 ;data input pin
BUSY equ P1.4
DOUT equ P1.3 ;data output pin
;input comand
;MEASURE_X equ 11011000B
;MEASURE_Y equ 10011000B

;*****************************************************************
;Code segment areas
;*****************************************************************
CSEG AT 0000H ;Code segment at 00H
ORG 00H
AJMP START ;Jump to start of program
ORG 1BH
AJMP Timer1 ;jump to timer1

ORG 30H
START:

MOV P1,#0FFH
CLR Busy_F
CLR Data_Ready_F
CLR Command_Ready_F
CLR Timer1_Ready_F
CLR Pos_Y_Measure_F
CLR Pos_X_Measure_F

; MOV TMOD,#20H ;8-bit timer mode (2)
; MOV TH1,#-10
; SETB TR1 ;Start timer 1
; SETB ET1 ;Enable timer 1 overflow interrupt
; SETB EA ;enable all interrupt

Loop:
; JNB Timer1_Ready_F,Loop_End
MOV Command_Buffer,#10011000B
SETB Pos_Y_Measure_F
ACALL Write_Command
MOV Command_Buffer,#11011000B
SETB Pos_X_Measure_F
ACALL Write_Command
; CLR Timer1_Ready_F

Loop_End:
SJMP Loop

;*****************************************************************
;Write command rountine
;*****************************************************************
Write_Command:
MOV A,Command_Buffer
MOV R0,#8
CLR DIN
CLR DCLK
SETB CS
CLR CS
Input_Loop:
MOV C,ACC.7
MOV DIN,C
CLR DCLK
SETB DCLK
RL A
DJNZ R0,Input_Loop
Input_Loop_End:
MOV Command_Buffer,A
JB Busy_F,$
MOV R0,#8
Output_Loop:
MOV C,DOUT
MOV ACC.7,C
CLR DCLK
SETB DCLK
RL A
DJNZ R0,Output_Loop
Output_Loop_End:
MOV Data_Buffer,A
JB Pos_X_Measure_F,Data_store_X
JB Pos_Y_Measure_F,Data_store_Y
Data_store_X:
MOV Data_Buffer_X,Data_Buffer
CLR Pos_X_Measure_F
SJMP Write_Command_End
Data_store_Y:
MOV Data_Buffer_Y,Data_Buffer
CLR Pos_Y_Measure_F

Write_Command_End:
RET

;*****************************************************************
;timer1 counting rountine
;*****************************************************************
Timer1:
PUSH PSW
PUSH ACC

SETB Timer1_Ready_F
Timer1_End:
POP ACC
POP PSW
RETI

;*****************************************************************
;Data segment areas
;*****************************************************************
DSEG AT 30H
Command_Buffer: DS 8
Data_Buffer: DS 8
Data_Buffer_X: DS 8
Data_Buffer_Y: DS 8

;*****************************************************************
;Flag bit segment areas
;*****************************************************************
BSEG AT 00H
Busy_F: DBIT 1 ;1=busy
Data_Ready_F: DBIT 1 ;1=Data ready
Command_Ready_F: DBIT 1 ;1=command ready
Timer1_Ready_F: DBIT 1 ;1=timer ready
Pos_X_Measure_F: DBIT 1
Pos_Y_Measure_F: DBIT 1


;*****************************************************************
;End of Program
;*****************************************************************
END
*滑块验证:
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

QQ|手机版|MCU资讯论坛 ( 京ICP备18035221号-2 )|网站地图

GMT+8, 2024-11-24 05:45 , Processed in 0.061182 second(s), 11 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表