Mercurial > public > ostc4
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 1068:3c3fb9f4edc4 | 1069:e0ba2b29dc1f |
|---|---|
| 199 if(nextChannel == MAX_ADC_CHANNEL) | 199 if(nextChannel == MAX_ADC_CHANNEL) |
| 200 { | 200 { |
| 201 nextChannel = 0; | 201 nextChannel = 0; |
| 202 } | 202 } |
| 203 | 203 |
| 204 while((psensorMap[nextChannel] != SENSOR_ANALOG) && (nextChannel != 0)) | 204 while((psensorMap[nextChannel] != SENSOR_ANALOG) && (nextChannel != activeChannel)) |
| 205 { | 205 { |
| 206 if(nextChannel == MAX_ADC_CHANNEL) | 206 if(nextChannel == MAX_ADC_CHANNEL) |
| 207 { | 207 { |
| 208 nextChannel = 0; | 208 nextChannel = 0; |
| 209 break; | |
| 210 } | 209 } |
| 211 else | 210 else |
| 212 { | 211 { |
| 213 nextChannel++; | 212 nextChannel++; |
| 214 } | 213 } |
| 215 } | 214 } |
| 216 | 215 |
| 217 activeChannel = nextChannel; | 216 |
| 218 if(activeChannel == 0) | 217 if(nextChannel <= activeChannel) /* new cycle or only one sensor connected */ |
| 219 { | 218 { |
| 220 startTickADC = HAL_GetTick(); | 219 startTickADC = HAL_GetTick(); |
| 221 delayAdcConversion = 1; /* wait for next cycle interval */ | 220 delayAdcConversion = 1; /* wait for next cycle interval */ |
| 222 } | 221 } |
| 223 else | 222 else |
| 224 { | 223 { |
| 225 externalInterface_StartConversion(activeChannel); | 224 externalInterface_StartConversion(nextChannel); |
| 226 } | 225 } |
| 227 timeoutCnt = 0; | 226 timeoutCnt = 0; |
| 227 activeChannel = nextChannel; | |
| 228 } | 228 } |
| 229 | 229 |
| 230 if(timeoutCnt++ >= ADC_TIMEOUT) | 230 if(timeoutCnt++ >= ADC_TIMEOUT) |
| 231 { | 231 { |
| 232 externalInterface_StartConversion(activeChannel); | 232 externalInterface_StartConversion(activeChannel); |
