2024-04-26 02:46 AM - edited 2024-04-26 03:45 AM
Hello ,
I want to make 4 channel PWM signal using TIM1 (with complimentory also) .While the TIM1 is used to triger the ADC to get sample .
I am getting the pwm wave , But ADC is not triggering or not working . What configuration i require
Please see more details below
I am Trying to generate 2 Channel PWM Genertaion [ CH1 CHN and PWD Generation CH2CH2N ] from DMA Buffer .
HAL_TIM_PWM_Start_DMA(&htim1, TIM_CHANNEL_1, (uint32_t *)sin_table, 160);
HAL_TIMEx_PWMN_Start_IT(&htim1, TIM_CHANNEL_1);
HAL_TIM_PWM_Start_DMA(&htim1, TIM_CHANNEL_2, (uint32_t *)sin_table, 160);
HAL_TIMEx_PWMN_Start_IT(&htim1, TIM_CHANNEL_2);
Configuration as follows
While PWM generation am trying to TIM1 is to triger the ADC
The ADC configured as follows
HAL_ADCEx_Calibration_Start(&hadc);
HAL_ADC_Start_DMA(&hadc, (uint32_t *)ADC_RES, 200);
Am here attached the main.c file
2024-04-26 04:01 AM - edited 2024-04-26 04:03 AM
Hi,
just what i see now : not enable continuous..
adc...dma:
+
see my use case : tim8 -> trigger -> adc (with dma )
tim8:
adc:
start in main.c : (but i use not circular dma here, doing just one 512 sample-shot.)
retval = HAL_ADC_Start_DMA(&hadc1, (uint32_t *) &sampels[nu][0], 512);
while(HAL_DMA_GetState(&hdma_adc1) > HAL_DMA_STATE_READY) {}; // wait for ready
2024-04-26 04:31 AM - edited 2024-04-26 04:41 AM
I tried DMA continuous. request turned off ?
If circular mode turn off is it restart from zero after 512 ?
Other configuration is correct in my case ?
In the below code i didnt get the trigger in GPIOC Pin4 what is the wrong with me ?
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{ if (htim->Instance == TIM1)
{ t occurs HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_4);
}
}
2024-04-26 04:48 AM - edited 2024-04-26 04:51 AM
>I tried DMA continuous. request turned off ?
Just try it.
>If circular mode turn off is it restart from zero after 512 ?
Yes, without circular mode : just filling the array one time. (Same as "one shot" on a DSO .)
Next dma start...same again.
>Other configuration is correct in my case ?
Hmmm...try. If you want continuous operation, then circular mode is correct; you have to use/copy data then in half/full callbacks - or just let it run. Only one dma-start needed here, it will loop always/endless and fill the array.