# HG changeset patch # User Ideenmodellierer # Date 1771357605 -3600 # Node ID e0ba2b29dc1f218bd08ece1d8bd9b868548bf2a6 # Parent 3c3fb9f4edc4931ea13ccd4fdcfbbbd336c182dd Dev Bugfix: Analog channel 0 overwrites digital channel 0: The search for the next analog channel was stopped in case the iteration is reset to zero => channel 0 was always sampled, even if no connected sensor was detected. This caused the values of a connected digital sensor to be overwritten. The search loop will now (again) iterate till it finds a new sensor or till the index reachs the active sensor index. diff -r 3c3fb9f4edc4 -r e0ba2b29dc1f Small_CPU/Src/externalInterface.c --- a/Small_CPU/Src/externalInterface.c Tue Feb 17 12:22:47 2026 +0100 +++ b/Small_CPU/Src/externalInterface.c Tue Feb 17 20:46:45 2026 +0100 @@ -201,12 +201,11 @@ nextChannel = 0; } - while((psensorMap[nextChannel] != SENSOR_ANALOG) && (nextChannel != 0)) + while((psensorMap[nextChannel] != SENSOR_ANALOG) && (nextChannel != activeChannel)) { if(nextChannel == MAX_ADC_CHANNEL) { nextChannel = 0; - break; } else { @@ -214,17 +213,18 @@ } } - activeChannel = nextChannel; - if(activeChannel == 0) + + if(nextChannel <= activeChannel) /* new cycle or only one sensor connected */ { startTickADC = HAL_GetTick(); - delayAdcConversion = 1; /* wait for next cycle interval */ + delayAdcConversion = 1; /* wait for next cycle interval */ } else { - externalInterface_StartConversion(activeChannel); + externalInterface_StartConversion(nextChannel); } timeoutCnt = 0; + activeChannel = nextChannel; } if(timeoutCnt++ >= ADC_TIMEOUT)