Check the manual, write the program, and discuss if there are any problems
*****************************************************************
//CPU:mega32
//Compiler:iar
#include "adc.h" int main(void) void adc_init(void) } int adc_get(char channel)
#include
{
int m;
adc_init();
m = adc_get(0);
m=m;
while(1);
}
{
ADMUX = 1<
{
int n;
if (channel > 7 && (ADMUX & 0x1f) <= 7 )
{
ADMUX = ADMUX & 0xE0 | channel;//Select channel
for(i=300;i>0;i--);//Converting to differential channel requires 125us delay! !
}
else
ADMUX = ADMUX & 0xE0 | channel;//Select channel
ADCSRA |= 1<<ADSC; //Start conversion
while( ADCSRA & (1<
n = n & 0x00ff | ADCH<<8 ;
return n;
}
Previous article:The simplest interrupt program for mega32 microcontroller - external interrupt
Next article:Some study notes on AVR microcontrollers
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- Today at 10:00 AM, live broadcast with prizes: [Introduction to TI's GaN-based applications]
- AD20.0.13 gets stuck when starting Adding View: Explorer under WIN10.
- Why are the high-precision positioning systems of Beidou and GPS not open to ordinary users?
- Low power solar cell charging
- What is the purpose of connecting multiple capacitors in parallel and using a polarized capacitor among them?
- Why are the wild elephants heading north? Use your imagination and make bold predictions!
- Bose small speaker disassembly
- Guangdong Tonly Semiconductor suffered a confined space suffocation accident: 4 workers from the outsourcing unit died
- LIS3MDL evaluation board STEVAL-MKI137V1 data
- TI Embedded Live Month: In-depth exploration of new applications of embedded products in industry and automobiles. The first live broadcast today at 10:00