m05e02 ok, calibration random

This commit is contained in:
hugogogo
2025-03-15 15:49:22 +01:00
parent e33261846b
commit 8365a79837
4 changed files with 31 additions and 27 deletions

View File

@@ -12,14 +12,14 @@
// - P = 64 -> Fadc = 16,000,000 / 64 = 250,000 = 250KHz -> OK
// - P = 128 -> Fadc = 16,000,000 / 128 = 125,000 = 125KHz -> OK
#define ADC_PRESCALER 128 // Table 24-5 : can only be 2, 4, 8, 16, 32, 64, or 128
#define ADC_PRESCALER 128 // Table 24-5 : can only be 2, 4, 8, 16, 32, 64, or 128
volatile uint8_t adc_channel = 0; // Table 14-6 : alternate function for RV1 on PC0 -> ADC0, LDR on PC1 -> ADC1, NTC on PC2 -> ADC2 ...
volatile uint8_t adc_channel = ADC_POTENTIOMETER; // Table 14-6 : alternate function for RV1 on PC0 -> ADC0, LDR on PC1 -> ADC1, NTC on PC2 -> ADC2 ...
// read 3 analog values at 10 bits and print them in uart as decimal : potentiometer RV1 (Variable Resistor), photoresistor LDR (Light Dependent Resistor), thermistor NTC (Negative Temperature Coefficient)
int main() {
char buffer[4];
SREG |= ENABLE_GLOBAL_INTERRUPT; // 7.3.1 : Status Register, bit 7 : I Global Interrupt Enable
SREG |= ENABLE_GLOBAL_INTERRUPT; // 7.3.1 : Status Register, bit 7 : I Global Interrupt Enable
uart_init();
adc_init(ADC_PRESCALER);