Commit c2bb8af7cc93452e7e420a9f405cf095a8a7cd07
authorga <ga@oldell.fish>
Tue, 26 Oct 2021 12:53:59 +0000 (13:53 +0100)
committerga <ga@oldell.fish>
Tue, 26 Oct 2021 12:56:14 +0000 (13:56 +0100)
3 files changed:
simavr/cores/sim_tinyx5.h
simavr/sim/avr_adc.h
tests/attiny85_adc_test.c

index 52f4bc7e26f35551c2f5f0ac8e6e288a82c70910..690e33814940f5ed8500f7b4bb77795c09fdc795 100644 (file)
@@ -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),
index 1bfee9eff633396b49d9c4a9acd6eefa090e9f13..f71279aee1c39e04b91a8a11a2bc4c7ec39461f8 100644 (file)
@@ -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
 
index 23643bfbdcc60a123a6b73328662c1ac01ffcbe7..c272ba7ab7a306d114001835310b8901f04eea25 100644 (file)
@@ -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])