first commit
This commit is contained in:
63
DISABELE_ADC/DISABELE_ADC.ino
Executable file
63
DISABELE_ADC/DISABELE_ADC.ino
Executable file
@@ -0,0 +1,63 @@
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
///////////////////////ADC INIT///////////////////////////////////////////////////
|
||||
// //DIDR0 = 0x00; //Digital input disabled on all ADC ports
|
||||
// PRR &= ~(1<<PRADC); //ADC turned on
|
||||
// ADMUX = 0x60; //AVcc, right adjusted, ADC0 pin
|
||||
// sei();
|
||||
// ADCSRA = 0xcF;
|
||||
//Serial.println(__FILE__);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
|
||||
Serial.print("ADCSRA = ");
|
||||
Serial.print(ADCSRA);
|
||||
Serial.print(" Save ADCSRA ");
|
||||
byte adcsra_save = ADCSRA;
|
||||
Serial.println(" Set ADCSRA = 0");
|
||||
//ADCSRA = 0;
|
||||
//ADCSRA = ADCSRA & B01111111;
|
||||
//delay(100);
|
||||
ADCSRA &= ~ bit(ADEN); bitSet(PRR, PRADC);
|
||||
Serial.print("ADCSRA = ");
|
||||
Serial.print(ADCSRA);
|
||||
Serial.print(" Analog read port A0 = ");
|
||||
Serial.print(analogRead(A0));
|
||||
Serial.print(" ADCSRA = ");
|
||||
Serial.println(ADCSRA);
|
||||
PRR &= ~(1<<PRADC);
|
||||
ADCSRA = adcsra_save;
|
||||
//delay(100);
|
||||
Serial.print("Restore ADCSRA");
|
||||
Serial.print(" ADCSRA = ");
|
||||
Serial.print(ADCSRA);
|
||||
Serial.print(" Analog read port A0 = ");
|
||||
Serial.println(analogRead(A0));
|
||||
Serial.println("-----------------------------------------------------------------");
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//// The following saves some extra power by disabling some
|
||||
//// peripherals I am not using.
|
||||
//
|
||||
//// Disable the ADC by setting the ADEN bit (bit 7) of the
|
||||
//// ADCSRA register to zero.
|
||||
//ADCSRA = ADCSRA & B01111111;
|
||||
//
|
||||
//// Disable the analog comparator by setting the ACD bit
|
||||
//// (bit 7) of the ACSR register to one.
|
||||
//ACSR = B10000000;
|
||||
//
|
||||
//// Disable digital input buffers on all analog input pins
|
||||
//// by setting bits 0-5 of the DIDR0 register to one.
|
||||
//// Of course, only do this if you are not using the analog
|
||||
//// inputs for your project.
|
||||
//DIDR0 = DIDR0 | B00111111;
|
||||
Reference in New Issue
Block a user