2023-08-24 11:43 AM - edited 2023-08-24 11:44 AM
Hi, I am working on a project using STM32L152. I have ADC DMA set up as I've used in many other projects using this part. For some reason this time around ADC values are not getting ready by the micro, and when I debug I find the DMA1_Channel1_IRQHandler is not getting called, even though the interrupt is set in the .ioc as normal.
Here is my .ioc configuration for ADC and interrupt priority, is there anything here that can suggest what the problem might be? I have cross referenced these settings with other working hardware projects and they are exactly the same as far as I can tell. Thanks!
Please see attached screenshots for .IOC settings.
2023-08-24 02:22 PM
In further debugging I find that the DMA interrupt runs twice, then reaches this ADC_DMAConvCplt function, then never runs again. Is there anything this behavior suggests is the cause of the error? All of this is automatically generated .IOC code so not something I have written or have a great understanding of.
2023-08-28 07:32 AM
Bump
2023-08-28 08:48 AM
Not enough info here to diagnose anything. The issue is likely with your code, not the CubeMX/IOC configuration and setup.
2023-08-28 09:05 AM
Show code, show registers.
DMA would expect HT and TC interrupts.
Won't repeat unless in circular mode. Will stop if hardware faults or addresses wrong. Check for errors on DMA or ADC peripherals..
If you have to Bump posts consider why. Is there sufficient detail to interest or diagnose?
2023-08-31 11:34 AM - edited 2023-08-31 11:42 AM
This is code being automatically generated by the .ioc, so I don't know what sharing it would express that .ioc settings do not. Is there some particular part of the generated files that it would be helpful to see directly?
2023-08-31 11:41 AM
Hey, as I stated in the question, this is an issue with code being automatically generated by the .ioc. I didn't write any of it, so I don't know what information copying the automatically generated files would express that sharing my .ioc settings does not. Is there a particular piece of information / part of that code that would help y'all to diagnose this?
2023-08-31 11:46 AM
2023-08-31 12:06 PM
Copy auto-generated files doesn't help a whole lot, you're right. However, nothing auto-generated will start the DMA. That is code you wrote, and that is what we're asking about here.
You didn't write this? It's in the user code section, seems like you did. That would be the useful thing to show.
2023-08-31 02:29 PM - edited 2023-08-31 02:31 PM
Okay, here is analog_main() the pedal_intialize() function where DMA is being kicked off, and the DMA function itself. DMA is started by calling:
adc_start(7); // Kick off perpetual ADC sampling
Which is implemented as follows:
#include "driver-adc.h"
extern ADC_HandleTypeDef hadc;
extern void Error_Handler(void);
uint16_t current_adc_vals[12];
void adc_start(uint8_t adc_channels) {
// Kick off next conversion
if(HAL_ADC_Start_DMA( &hadc, (uint32_t *) current_adc_vals, adc_channels ) != HAL_OK) {
Error_Handler();
}
}
This code is all completely unchanged from other STM32L152 projects where it works without any problems, but please let me know if this points to anything and if there's any other information I can share to make it easier to diagnose.