Skip to main content
Lead
June 20, 2021
Solved

How can I use Capture Compare as external trigger source?

Hi!

This might be a simple question, but I still haven't solved it.

I want to create an external trigger source for SDADC 16-bit and I have selected TIM12 Capture Compare 1 as external trigger source.

0693W00000BbUBbQAN.png 

Then I have enable the Output Compare, because I did not find Capture Compare.

0693W00000BbUBgQAN.png 

Then I enable the NVIC for the SDADC.

	HAL_TIM_Base_Start(htim13); /* TIM13 is trigger source for SDADC1 */
	HAL_TIM_Base_Start(htim12); /* TIM12 is trigger source for SDADC2 */
	HAL_TIM_Base_Start(htim16); /* TIM16 is trigger source for SDADC3 */
	if (HAL_SDADC_InjectedStart_IT(hsdadc1) != HAL_OK)
		Error_Handler();
	if (HAL_SDADC_InjectedStart_IT(hsdadc2) != HAL_OK)
		Error_Handler();
	if (HAL_SDADC_InjectedStart_IT(hsdadc3) != HAL_OK) /* Differential only */
		Error_Handler();

But still. Nothing happens when I have this function avaiable.

This never calls. Why?

/* Callbacks for SDADC */
void HAL_SDADC_InjectedConvCpltCallback(SDADC_HandleTypeDef *hsdadc){
	if(hsdadc->Instance == SDADC1) {
		STM32_PLC_Analog_Input_SDADC1(hsdadc);
	}else if (hsdadc->Instance == SDADC2) {
		STM32_PLC_Analog_Input_SDADC2(hsdadc);
	}else if (hsdadc->Instance == SDADC3) {
		STM32_PLC_Analog_Input_SDADC3(hsdadc);
	}
}

This topic has been closed for replies.
TDK
TDKBest answer
June 21, 2021

Include your chip part number.

You start the timer, but I don't see you starting the channel anywhere. Should be a call to HAL_TIM_OC_Start or similar.

"If you feel a post has answered your question, please click ""Accept as Solution""."

5 replies

TDK
TDKBest answer
June 21, 2021

Include your chip part number.

You start the timer, but I don't see you starting the channel anywhere. Should be a call to HAL_TIM_OC_Start or similar.

"If you feel a post has answered your question, please click ""Accept as Solution""."
DMårtAuthor
Lead
June 21, 2021

Did not work to use HAL_TIM_OC_Start(htim, TIM_CHANNEL_x)

STM32MP151AAC3 custom board with STM32-OS as operating system: https://github.com/DanielMartensson/STM32-ComputerSTM32MP257FAK3 custom board with STM64-OS as operating system: https://github.com/DanielMartensson/STM64-Computer
waclawek.jan
Super User
June 21, 2021

If you want to trigger the SDADC using a signal coming from outside the STM32, you have to set the timer's channel to Input Capture.

Read the timer chapter in RM.

JW

DMårtAuthor
Lead
June 21, 2021

So if I want a trigger source that using a signal inside the STM32. How should I do then?

STM32MP151AAC3 custom board with STM32-OS as operating system: https://github.com/DanielMartensson/STM32-ComputerSTM32MP257FAK3 custom board with STM64-OS as operating system: https://github.com/DanielMartensson/STM64-Computer