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

📄 potread.asm

📁 包括了各种常用的8051单片机的程序
💻 ASM
字号:
;  PotRead - Read the Pot Values And Output a Pulse Showing What Was Read 
;
;  This Application Reads Resistance Values by Allowing a Capacitor 
;   Wired to a Pot to Charge and then Measure the Time the Cap takes
;   To Discharge.  
;
;  Two Inputs are used, P1.0 and P1.1 and the Resistance is a Joystick
;   With Resistances from 0 to 50K Ohms.  A 0.1 uF cap is used as the 
;   Charge Source and a 150 Ohm Resistor to Vcc to allow the Cap to Charge 
;   without Having a Short to Vcc (and a Voltage Source Because the P1.0 and
;   P1.1 Pins do not have internal pull-ups).  
;
;  Myke Predko
;  98.05.09
;
;  Hardware Notes:
;  89C2051 Running at 10 MHz
;  P1.0 is Connected to a Joystick Pot via the Circuit Described Above.
;  P1.1 is Connected to a Joystick Pot via the Circuit Described Above.
;  P1.6 is Used as the Pulse Output for P1.0
;  P1.7 is Used as the Pulse Output for P1.1


;  Variable Declarations

 org 0
Mainline:                       ;  Program Mainline

  mov    P1,#%00111110          ;  Drop the P1.0 Line and Wait for it to Go Low

  mov    R0,#0FFh               ;  Let the Cap Discharge
Loop1:
  djnz   R0,Loop1

  mov    P1,#%01111111          ;  Now, Wait for the Cap to Charge

Loop2:                          ;  Loop Until the the Line Becomes High
  jnb    P1.0,Loop2

  mov    P1,#%00111101          ;  Drop the P1.1 Line and Wait for it to Go Low

  mov    R0,#0FFh               ;  Let the Cap Discharge
Loop3:
  djnz   R0,Loop3

  mov    P1,#%10111111          ;  Now, Wait for the Cap to Charge

Loop4:                          ;  Loop Until the the Line Becomes High
  jnb    P1.1,Loop4

  clr    P1.7                   ;  Finished, Drop the P1 Line to Indicate it's Done

  ajmp   Mainline               ;  Loop Back Around to the Mainline

⌨️ 快捷键说明

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