darrylring opened a new pull request, #21397:
URL: https://github.com/apache/nuttx/pull/21397

   ## Summary
   
   When multiple ADCs are enabled it's currently possible for an interrupt for 
one ADC to run the interrupt handler for another ADC, even if there are no 
enabled interrupts to handle.
   
   As an example, the EOC (end of conversion) interrupt is disabled when the 
ADC is used in DMA mode. The EOC flag, however, still gets set, so an interrupt 
on the other ADC will try to handle both interrupts. This will mean the non-DMA 
mode path gets called as well as the DMA path. Or in the case of a driver using 
`ao_bind`, if `ao_receive = NULL` (for a DMA-only driver), a `DEBUGASSERT` or 
null dereference.
   
   This change ensures that only enabled interrupts are handled.
   
   I believe the H7 and L4 are also affected, but I don't have any test setups 
for those parts.
   
   ## Impact
   
   The driver always enables the interrupts it actually handles, so this will 
have no impact on interrupts from being serviced. The impact is, therefore, an 
additional register read and an AND.
   
   ## Testing
   
   First and foremost, my code that used to crash now doesn't crash!
   
   Claude wrote a little test application for the NUCLEO-H563ZI which enables 
ADC1 in circular DMA mode sampling PA6 tied to GND and PC0 tied to 3V3, and 
spams ADC2 reads (of PA6) from a separate thread. It then checks that the the 
DMA'ed samples are the correct values in the correct order.
   
   
[adc-test.patch](https://github.com/user-attachments/files/34295391/adc-test.patch)
   
   After:
   
   ```
   ADC test: running for 10 s
   ADC test: ch3 0..12, ch10 4079..4095
   ADC test: ADC2 PA6 0..50
   ADC test: 1148256 samples, 0 order errors, 0 value errors: PASS
   ```
   
   Before:
   
   ```
   ADC test: running for 10 s
   ADC test: ch3 0..4095, ch10 0..4095
   ADC test: ADC2 PA6 0..50
   ADC test: 1148452 samples, 196 order errors, 102 value errors: FAIL
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to