cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F446RE ADC Tripple injected simultaneous mode triggerd by Timer 1

Mhoko.1
Associate

Hello,

i want to use the STM32F446RE MC to controll a PMSM. For that reason I need to measure 2-3 currents simultaneously.

I'm working with CubeMX used for the initialization and Keil for the further programming.

Also i am mainly using the HAL functions, i know it could be easier using the registers directly due to lack of informations about the whole HAL functions but I have already spent a lot of time reading manuals and watching videos etc. about that HAL way so it would be nice to get it working that way.

Also I don't want to trigger the ADCs with the software, but directly by the timer (external Trigger TIM1).

A picture of my CubeMX configuartion of ADC1 & 2 and TIM1 are attached to this post.

So, my problem is that you always have to "manually" start the timers and ADCs using the right HAL command and I couldn't find out which to use for my case.

As far as I understood I could have to use

  • HAL_ADCEx_MultiModeStart_DMA(&hadc1, (uint32_t *)VariableToStoreConvertedValues, 3)

for ADC1

  • HAL_ADCEx_InjectedStart_IT(&hadc3) for ADC3
  • HAL_ADCEx_InjectedStart_IT(&hadc2) for ADC2
  • HAL_TIM_Base_Start(&htim1) for TIM1

and get all of them into "USER CODE 2", after the initialization of the ADCs etc.

My first goal is to toggle a pin using

void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef* hadc)
{
  
	HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_7);
 
}

at the end of the main-function (ADC1,2,3 Interrupt is enabled).

Unfortunately I couldn't find any usfull explanation on how to get the Triple Injected Mode to work, the user manual just states how it works in gerneral and talks about the registers (which would be the easier way, I know..) and the manual about the HAL functions is even more usless for my case. DMA is also activated but not used yet.

Quick summary:

Want to get three ADCs working simultaneously using the tripple injected simultaneous mode, which is triggered directly by Timer 1 Channel 4 (Output compare for example) working as an external trigger. Using CubeMX & Keil. Searching for matching HAL functions.

Greetings

Alex

0690X00000AtVFMQA3.png0690X00000AtVEiQAN.png0690X00000AtVGAQA3.png

0 REPLIES 0