From c2bb8af7cc93452e7e420a9f405cf095a8a7cd07 Mon Sep 17 00:00:00 2001 From: ga Date: Tue, 26 Oct 2021 13:53:59 +0100 Subject: [PATCH] Fix attinyx5 ADC multiplexor values. --- simavr/cores/sim_tinyx5.h | 7 ++++--- simavr/sim/avr_adc.h | 2 +- tests/attiny85_adc_test.c | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/simavr/cores/sim_tinyx5.h b/simavr/cores/sim_tinyx5.h index 52f4bc7..690e338 100644 --- a/simavr/cores/sim_tinyx5.h +++ b/simavr/cores/sim_tinyx5.h @@ -107,9 +107,10 @@ const struct mcu_t SIM_CORENAME = { AVR_IO_REGBIT(ADMUX, MUX2), AVR_IO_REGBIT(ADMUX, MUX3),}, .ref = { AVR_IO_REGBIT(ADMUX, REFS0), AVR_IO_REGBIT(ADMUX, REFS1), AVR_IO_REGBIT(ADMUX, REFS2), }, .ref_values = { - [0] = ADC_VREF_VCC, [1] = ADC_VREF_AVCC, - [2] = ADC_VREF_V110, [5] = ADC_VREF_V256, - [6] = ADC_VREF_V256, + [0] = ADC_VREF_VCC, + [2] = ADC_VREF_V110, + [4] = ADC_VREF_VCC, + [6] = ADC_VREF_V256, [7] = ADC_VREF_V256, }, .adlar = AVR_IO_REGBIT(ADMUX, ADLAR), diff --git a/simavr/sim/avr_adc.h b/simavr/sim/avr_adc.h index 1bfee9e..f71279a 100644 --- a/simavr/sim/avr_adc.h +++ b/simavr/sim/avr_adc.h @@ -108,7 +108,7 @@ typedef struct avr_adc_t { // if the last bit exists in the mux, we are an extended ADC avr_regbit_t mux[6]; avr_regbit_t ref[3]; // reference voltages bits - uint16_t ref_values[7]; // ADC_VREF_* + uint16_t ref_values[8]; // ADC_VREF_* avr_regbit_t adlar; // left/right adjustment bit diff --git a/tests/attiny85_adc_test.c b/tests/attiny85_adc_test.c index 23643bf..c272ba7 100644 --- a/tests/attiny85_adc_test.c +++ b/tests/attiny85_adc_test.c @@ -65,7 +65,7 @@ static struct params { {0x9a, 0x80}, // 2.56V ref, ADC0/ADC1 differential, signed +ve overflow {0x9a, 0x80}, // 2.56V ref, ADC0/ADC1 differential, signed, positive {0x86, 0x80}, // 1.10V ref, ADC2/ADC3 differential, signed, -ve overflow - {0x13, 0 }, // 3.00 V external ref, input ADC3 + {0x43, 0 }, // 3.00 V external ref, input ADC3 }; #define NUM_SUBTESTS (sizeof params / sizeof params[0]) -- 2.39.5