0

I'm trying to set up my STM32 to read signals from both ADC 1 and 2 through DMA, while keeping the rest of my program running through FreeRTOS tasks scheduling.

At this moment, my tasks only manage leds and pins, running smoothly and in a well-timed manner.

I run into issues as soon as I start the DMA with HAL_ADC_Start_DMA. The program goes into HardFault, with the debug runtime looking as following: Debug Runtime going into hardfault.

ReadTask01 is the first task being launched.

I'm new in embedded programming, but for what I can grasp it must be an issue with competing timers, with TIM6 being the TimeBase source. Timers priority

I'm actually stuck here, really not knowing which buttons to push. I'm also not sure which configuration code should I post here, but if you have any hint I'll follow up as soon as possible.

Thank you very much

EDIT1:

if I have my HAL_ADC_Start_DMA started into a task, so after the osKernel is started, I go into the Hardfault passing by PendSV_Handler, as shown here.

As commented below, I think the Hardfault isn't because of any DAC, since I haven't any, but from the TIM6, whicjh I set as Timebase Source.

3
  • You seem to have things going on with a DAC also, which muddies the water. Can you remove the DAC stuff from your code and make things simpler? Also make sure that your stack size is big enough for all your interrupts to happen at the same time. You have a timer interrupt and a DAC interrupt happening at the same time. Commented Nov 6, 2023 at 0:44
  • @pmacfarlane the TIM6_DAC_IRQHandler as stated in the brief: This function handles Timer 6 interrupt and DAC underrun interrupts. I have no DAC set, i only have GPIO digital inputs, outputs and ADC inputs. So I guess this IRQHandler is there just for the TIM6. I use it as Timebase Source, set up in SYS. If I update the firmware in order to have the ADC_Start_DMA launched after FreeRTOS osKernelStart, ad example having it in a specific task, I get the HardFault after getting into PendSV_Handler, as shown in the new edit above. Commented Nov 6, 2023 at 11:01
  • @pmacfarlane I confirm that is directly related to any Timebase is use as Source, if I change it for example to TIM1, that's where I pass through right before having getting to the HardFault_Handler. I checked its priority in System Code -> NVIC and TIM6 is set as the one with less priority. If I don't find a solution, I think I'll just poll each ADC channel singularly, since I can't seem to be able to have FreeRTOS and DMA together Commented Nov 6, 2023 at 12:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.