Generate a frequency burst
- April 7, 2021
- 8 replies
- 3416 views
Hello,
i try to implement a 40kHz frequency burst with my NULCEO STM32F411RE. Until now i toggle the GPIO continuously in the HAL_TIM_PWM_PulseFinishedCallback function. But now i have to implement a start Trigger to do a small 40kHz burst. In the attached picture where you can see the yellow start trigger which should start my burst signal. To be flexible with the amplitude, i used the external DAC MCP4921. But as you can see (green signal), sometimes the code is executed faster, which generates a phaseshift. Thats why i want to implement this burst with an GPIO, but i will lose the functionallity of an flexible amplitude. I tried to use the Status Register UIF bit (Update interrupt flag) , which generates an impluse when the counter has overflown. but the result is not 40kHz (scope_4 blue signal). I changed the prescaler of my timer but nothing changed. I guess i have to use a different method.
void PM(void)
{
GPIOA->BSRR = (1<<24);;
for(int p=0;p<=40;p++)
{
if(TIM2->SR & 0x01)
GPIOA->ODR ^= (1<<8); //Toggle output GPIOA PA8
}
GPIOA->BSRR = (1<<24);
}This is the function right after i read the yellow trigger Signal with
if(HAL_GPIO_ReadPin(I_Trigger_GPIO_Port, I_Trigger_Pin)== GPIO_PIN_SET)How i could use the 40kHz of TIM2 to toggle my GPIO
