void adc_init(void)
{
ADCSRA = 0x00; //Disable ADC
ADMUX = 0x03;
ACSR = 0x80; //Disable analog comparator
ADCSRB = 0x00;
ADCSRA = 0x83;
}
uint read_adc(void)
{
uint temp = 0;
ADCSRA |= (1 << ADSC); // Enable AD conversion, first conversion, result discarded
while((ADCSRA & (1 << ADIF)) == 0); //Wait for AD conversion to finish
ADCSRA |= (1 << ADIF); //Write 1 to clear ADIF, as required by the specification
ADCSRA |= (1 << ADSC); // Enable AD conversion, second conversion, the result is retained
while((ADCSRA & (1 << ADIF)) == 0); //Wait for AD conversion to finish
ADCSRA |= (1 << ADIF);
temp = ADCL;
temp |= (int)(ADCH << 8);
return temp;
}
Previous article:ATtiny13A ADC interrupt usage
Next article:ATtiny13A EEPROM read and write functions
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
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
- Detailed explanation of intelligent car body perception system
- How to solve the problem that the servo drive is not enabled
- Why does the servo drive not power on?
- What point should I connect to when the servo is turned on?
- How to turn on the internal enable of Panasonic servo drive?
- What is the rigidity setting of Panasonic servo drive?
- How to change the inertia ratio of Panasonic servo drive
- What is the inertia ratio of the servo motor?
- Is it better for the motor to have a large or small moment of inertia?
- What is the difference between low inertia and high inertia of servo motors?
- How to deduce normalized parameters from transfer functions and then design filters
- Output swings to GND Single supply, low side, unidirectional current circuit
- About the problem of converting schematic diagram to PCB when designing RF PCB circuit
- QSPI read, write and erase flash
- 【CH579M-R1】+OTA principle and source code analysis
- [TI millimeter wave radar evaluation] 3+AWR1443 EVM board test case 2
- Waiting online, I don't understand a lot about this circuit, I hope someone can teach me
- Problems with emwin switching interface
- TMS320C6000 Series Interrupts
- Arteli-USB read RAM buffer usage specification recommendations