tmp broken
This commit is contained in:
@@ -19,8 +19,9 @@ void adc_init(uint8_t prescaler_value) {
|
||||
uint16_t adc_read(uint8_t channel) {
|
||||
CLEAR(PRR, PRADC); // 24.3 : ensure power reduction is disabled for ADC, (10.11.3 : PRR – Power Reduction Register)
|
||||
ADMUX = (ADMUX & 0b11110000) | (channel & 0b1111); // Table 24-4 : Select ADC channel, (Table 14-6 : alternate function for RV1 on PC0 -> ADC0)
|
||||
// ADMUX |= (1 << ADLAR); // Enable left adjust result
|
||||
// ADMUX |= (1 << ADLAR); // 24.9.3 : enable left adjust result
|
||||
ADCSRA |= (1 << ADSC); // 24.9.2 : Start conversion, ADSC: ADC Start Conversion
|
||||
while (ADCSRA & (1 << ADSC)); // Wait for completion
|
||||
return ADCH; // TODO: p247, read ADCH when left adjusted to only read 8 bits
|
||||
// return ADCH; // 24.9.3 : ADC updated only when ADCH is read, not ADCL, so for 8 bits precision uses left adjust result to only read ADCH
|
||||
return ADC;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user