;This program is a simple AD conversion demonstration program, which performs 0-5V voltage test
;The conversion result is output from port C and is very intuitive
;The converted value ADRESH is 0 at 0V, and the LEDs are all off, and all light up at 5V
;================================================
include
ORG 0X00
NOP
START
BCF STATUS,RP0
CLRF PORTC
MOVLW B'01000001' ;D7 D6=01 AD conversion clock frequency = FOSC/8
MOVWF ADCON0 ;D5 D4 D3=000 AD conversion analog channel selection RA0/AN0
;D2=0 AD completed or not in progress D0=0 turn off ADC
BSF STATUS,RP0
MOVLW B'10000111' ;D7=1 cancel pull-up, D6=0 INT falling edge trigger,
MOVWF OPTION_REG ;D5=0 TOCK1 uses internal clock D4=0 TOCK1 rising edge increment
; D3=0 for TMR0 D2 D1 D0=1 TMR0 1:256 division
CLRF TRISC
MOVLW B'00001110' ;D3 D2 D1 D0 1110 selects RA0 as the analog port.
MOVWF ADCON1; D7=0 left-aligned The lower six bits of ADRESL are read as 0
BCF STATUS, RP0
MAIN
BTFSS INTCON,T0IF ; Wait for TMR0 timer overflow interrupt
GOTO MAIN
BCF INTCON,T0IF ; Clear TMR0 timer overflow flag
BSF ADCON0,GO ; Turn on A/D
WAIT
BTFSS PIR1,ADIF ; Wait for A/D to complete
GOTO WAIT
MOVF ADRES,W ; A/D value is output from PORTC
MOVWF PORTC
GOTO MAIN
END
Previous article:PIC16F873 A/D conversion program
Next article:PIC microcontroller A/D conversion process
- Popular Resources
- Popular amplifiers
- STC8 series MCU development guide: analysis and application of processors, programming and operating systems
- Compilation system perspective: Graphical explanation of the working mechanism and implementation principle of the GCC compiler
- Principles of Compilation 3rd Edition (Zhang Suqin, Wang Shengyuan, Dong Yuan, Lü Yingzhi, Jiang Weidu)
- Decompilation technology and software reverse analysis
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
- When the comparator output is connected to the logic OR gate input, it cannot generate a high voltage signal (logic "1"), how to solve it?
- [NXP Rapid IoT Review] "Smart Home Control System Based on Rapid IoT" - Review Summary
- Advantages of TI's multi-channel PA controller AMC7932 in MIMO systems
- 555 classic circuit diagram: DC-AC converter diagram composed of 555 circuit
- Is there any mobile phone positioning software that you would recommend?
- TI Live: A detailed discussion of a candidate solution for "electric vehicle on-board charger". Will it be popular among engineers?
- DSPC6678 on-chip storage space allocation mechanism
- EEWORLD University Hall ---- Computer Control Devices Zhang Guangxin of Zhejiang University
- The most worrying thing happened: ARM complies with new US regulations and stops cooperating with Huawei
- Summary of remote firmware upgrade for MSP430, STM8L, cortex-M0 core