2025-03-10 11:02 PM
Hii,
I am using hrtim in stm32G474RET6 mcu, so i want to know how we generate a counter of 500ns in which i call adc in it.
If somebody know about it please help me.
Solved! Go to Solution.
2025-03-26 6:58 AM
Hi @Harsh_18,
You can use a DMA request. The ADC is capable of generating this request to notify the DMA of the end of the conversion. The best way to use the DMA with the ADC is in continuous mode, with a DMA destination (a variable in memory), so that the user can use this variable without worrying about when it is updated by the ADC. When the ADC completes the conversion, it generates a request to the DMA, which copies it into this variable. Since continuous mode is enabled and the DMA is in circular mode, all the previous steps will restart automatically.
Here is the necessary configuration for this behavior:
For starting the ADC with DMA and specifying the destination variable, you could use:
if (HAL_ADC_Start_DMA(&hadc1, (uint32_t *) &VARIABLE_DESTINATION, 1) != HAL_OK)
{
/* ADC initiliazation Error */
Error_Handler();
}
Thank you.
ELABI.1
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-03-12 1:59 AM
Hi @Harsh_18,
You can refer to the Application Note AN5305, specifically section "2.8 Configuring the high-resolution timer". Additionally, you can consult the HRTIMcookbook, which can help you.
Thank you.
ELABI.1
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-03-17 9:44 PM
Hi @ELABI.1,
I worked on hal driver, so can you please guide me.
2025-03-19 4:39 AM
Hi @Harsh_18?,
To generate a 500 ns PWM, you need to program and activate a counter with: HAL_HRTIM_WaveformCounterStart_IT(&hhrtim1, HRTIM_TIMERID_TIMER_A); / HAL_HRTIM_WaveformOutputStart(&hhrtim1, HRTIM_OUTPUT_TA1) for example, and generate a trigger to the ADC by this Timer unit, you can program the trigger at the beginning of the period:
Then on ADC side, you need to bind this trigger to conversion source, so ADC will start working when triggered by hrtimer period:
I hope that I was able to help you.
Thank you.
ELABI.1
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-03-25 9:12 AM
Hi @ELABI.1,
Firstly thank you soo much for helping me. Can you please give me some more favour i.e. is this adc work in dma mode .
Another is i want to execute same code less than 10us but my adc(with dma) consume too much time .So what i do for that.
2025-03-26 6:58 AM
Hi @Harsh_18,
You can use a DMA request. The ADC is capable of generating this request to notify the DMA of the end of the conversion. The best way to use the DMA with the ADC is in continuous mode, with a DMA destination (a variable in memory), so that the user can use this variable without worrying about when it is updated by the ADC. When the ADC completes the conversion, it generates a request to the DMA, which copies it into this variable. Since continuous mode is enabled and the DMA is in circular mode, all the previous steps will restart automatically.
Here is the necessary configuration for this behavior:
For starting the ADC with DMA and specifying the destination variable, you could use:
if (HAL_ADC_Start_DMA(&hadc1, (uint32_t *) &VARIABLE_DESTINATION, 1) != HAL_OK)
{
/* ADC initiliazation Error */
Error_Handler();
}
Thank you.
ELABI.1
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-03-27 3:31 AM
Thanks, and the last one is how we create the irq timer of 1us through hrtim
2025-03-27 5:32 AM
Here is the necessary configuration to create the 1µs IRQ timer using HRTIM:
Thank you.
ELABI.1
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.