diff Small_CPU/Src/externalInterface.c @ 1069:e0ba2b29dc1f Icon_Integration tip

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.
author Ideenmodellierer
date Tue, 17 Feb 2026 20:46:45 +0100
parents 1f2067cad41b
children
line wrap: on
line diff
--- 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)