fix 8 bit precision in ex00 and ex01
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
|
||||
void adc_init(uint8_t prescaler_value) {
|
||||
ADMUX = (1 << REFS0); // Table 24-3 : set voltage reference, AVCC with external capacitor at AREF pin
|
||||
ADMUX |= (1 << ADLAR); // 24.9.1 : result is left adjusted, meaning the first 8 bits values are readable in ADCH, (24.9.3.2 : ADC data register is not updated util ADCH is read)
|
||||
ADCSRA = (1 << ADEN); // 24.9.2 : enable ADC
|
||||
ADCSRA |= (1 << ADATE); // 24.9.2 : enable Auto Trigger -> it will start a conversion on the selected channel in ADMUX when the selected source (in ADCSRB) is triggered
|
||||
ADCSRA |= (1 << ADIE); // 24.9.2 : enable ADC Interrupt
|
||||
@@ -29,6 +30,6 @@ void adc_print_hex(uint8_t value) {
|
||||
}
|
||||
|
||||
ISR(ADC_vect) { // Table 12-6 : interrupt vector for ADC Conversion Complete
|
||||
uint16_t value = ADC;
|
||||
uint8_t value = ADCH; // 24.9.3.2 : read ADCH 8 bits precision
|
||||
adc_print_hex(value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user