;The A/D test program for PIC16F873 implements the following functions:
;(1) Use RA0/AN0 as the A/D conversion input channel;
;(2) The reference voltage source VREF selects the internal VDD and VSS;
;(3) The A/D conversion clock source selects a 4MHz oscillator;
;(4) Eight-bit data accuracy, and the AD result is written to port C.
;8L8ADSY.ASM A/D conversion
list p=16f873
INCLUDE "P16F873.INC"
ORG 0x000
MAIN
NOP
BANKSEL ADCON1 ;Select RAM data memory bank 1, equivalent to BSF STATUS, RP0
MOVLW B'00000000' ;Select RA5/AN4 as analog input, the result format is left-aligned
MOVWF ADCON1 ;Select internal VDD and VSS for reference voltage source VREF
CLRF TRISC ;Set port C as output
BANKSEL ADCON0 ;Select RAM data memory bank 0, equivalent to BCF STATUS, RP0
MOVLW B'01100001' ;Set clock source 8Tosc, enable ADC, AN0 channel is selected
MOVWF ADCON0
CLRF PORTC ;Clear port C
AtoD
NOP; In order to ensure the sampling time, usually,
a NOP of more than 20us should be inserted; Time delay or arrange a considerable length of application.
BSF ADCON0,GO; GO position 1, start A/D conversion
ADWAIT
BTFSC ADCON0,GO; After the A/D conversion is completed, the GO bit will be cleared to 0
GOTO ADWAIT; If the conversion is not completed, return to continue testing
MOVF ADRESH,W; If the conversion is completed, read the A/D result into W
MOVWF PORTC; Write the AD result to port C
GOTO AtoD; Cycle A/D conversion
END
Previous article:PIC microcontroller commonly used 1s delay subroutine
Next article:AD conversion assembly program example
Recommended ReadingLatest update time:2024-11-16 13:26
- Popular Resources
- Popular amplifiers
- Microgrid Stability Analysis and Control Microgrid Modeling Stability Analysis and Control to Improve Power Distribution and Power Flow Control (
- Signal and System Experiment Tutorial (Edited by Jin Bo)
- Effective Unit Testing (Lasse Koskela)
- Operational Amplifier Practical Reference Handbook (Edited by Liu Changsheng, Zhao Mingying, Liu Xu, etc.)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- How to use C2000 CSM
- Tianjin in my eyes in 2020
- TI DSP C6000 structural knowledge
- LSD-FET430UIF wiring diagram
- Grab the post! A wave of high-quality tutorials is coming, comment and forward the tutorials to get gifts! Cheer for the 2019 National Competition~
- [N32L43X Review] 5. Hardware SPI driver for OLED
- Methods for reducing board size and battery consumption in low voltage H-bridge applications
- When the LSM6DS3TR-C is configured with the I2C address, the power consumption is high when the SA0 pin is connected to GND.
- Regarding MCU, here are some ideas for R&D!
- [Erha image recognition artificial intelligence visual sensor] 2: Erha visual sensor and host computer serial port communication experiment