File Name :main.c illustrate: 1. Query mode A/D conversion test program =============================================================*/ #include#include #define uchar unsigned char #define uint unsigned int uint AdcConvert(void) { unsigned char i; unsigned int ret; ADMUX=0X40; //Internal 2.56V reference voltage, channel 0 ADCSRA=_BV(ADEN); // Enable ADC, single conversion mode ADEN=7 ADCSRA|=_BV(ADSC); //ADC starts converting ADSC=6 while(ADCSRA&_BV(ADSC)) ; // Wait for the conversion to end right=ADCL; ret|=(uint)(ADCH<<8); ret=ret/4; // Convert 10 bits to 8 bits, and use 8 LEDs to display the result ADCSRA=0; // Turn off ADC return right; } int main(void) { DDRF=0x00; DDRA=0XFF; while(1) { PORTA=AdcConvert(); } }
Previous article:BCD code conversion and calculation in the implementation of Mege16 AVR microcontroller
Next article:51. IO port operation of AVR and PIC
Recommended ReadingLatest update time:2024-11-16 12:56
- Popular Resources
- Popular amplifiers
- Microgrid Stability Analysis and Control Microgrid Modeling Stability Analysis and Control to Improve Power Distribution and Power Flow Control (
- Introduction to Internet of Things Engineering 2nd Edition (Gongyi Wu)
- Signal and System Experiment Tutorial (Edited by Jin Bo)
- Permanent Magnet Synchronous Motor Speed Control System Control Technology (by Hou Limin and Wang Wei)
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 get the starting and ending coordinates of the touch screen
- The idea of implementing crawlers
- Design and implementation of temperature controller based on single chip microcomputer and fuzzy control
- I'm moving, so I'm selling some nearly new boards.
- Lichee RV 86 PANEL Review (2)——System Burning and Application
- Non-isolated 'mains' voltage acquisition circuit
- [GD32L233C-START Review] 1. GD32L233C-START with obvious advantages and disadvantages (unboxing)
- LTC2325-16 Sampling Issues
- Design considerations for single-chip microcomputer key scanning program
- How to change the library file in the schematic diagram in orcad?