2022-08-13 09:54 AM
I have a sensor which generate an input signal. By using this signal rising edge , I want to generate some pwm signals and additional Dac signal from DMA which synchronize with input Signal. When I visualize signals on ossiloscope , I aware some slip between signals and it is not stable. if you have any suggest or method please help me.
I use GPIO EXT to capture input signal.
Tim5 to control Dac Sıgnal
Other Timers for Pwm Signal
My Code is below.
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
if(GPIO_Pin == GPIO_PIN_1)
{
i++;
if(i % 20 == 0)
{
HAL_TIM_PWM_Start_IT(&htim3, TIM_CHANNEL_1);
HAL_TIM_PWM_Start_IT(&htim2, TIM_CHANNEL_1);
HAL_TIM_PWM_Start_IT(&htim4, TIM_CHANNEL_1);
// HAL_TIM_Base_Start_IT(&htim5);
// HAL_DAC_Start_DMA(&hdac, DAC_CHANNEL_1, MySignal, 200, DAC_ALIGN_12B_R);
// HAL_TIM_PWM_Start_IT(&htim3, TIM_CHANNEL_1);
TIM2-> CNT = 0;
TIM4-> CNT = 0;
TIM3-> CNT = 0;
// TIM5-> CNT = 0;
}
HAL_TIM_PWM_Start_IT(&htim2, TIM_CHANNEL_1);
HAL_TIM_PWM_Start_IT(&htim4, TIM_CHANNEL_1);
HAL_TIM_Base_Start_IT(&htim5);
// HAL_DAC_Start_DMA(&hdac, DAC_CHANNEL_1, laserSignal, 200, DAC_ALIGN_12B_R);
// HAL_TIM_PWM_Start_IT(&htim3, TIM_CHANNEL_1);
TIM2->CNT = 0;
TIM4->CNT = 0;
// TIM5->CNT = 0;
TIM3->CNT = 0;
// DAC->CR = RESET;
// __HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin);
}