cancel
Showing results for 
Search instead for 
Did you mean: 

Stm32F4 Discovery Generate Pwm signals have different frequencies and Dac Signal with DMA

AAlk.1
Associate

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);

}0693W00000QNd3EQAT.png0693W00000QNd39QAD.png0693W00000QNd34QAD.png0693W00000QNd2uQAD.png0693W00000QNd2pQAD.png0693W00000QNd2kQAD.png0693W00000QNd2fQAD.png0693W00000QNd2aQAD.png0693W00000QNd2VQAT.png

0 REPLIES 0