GPIO, ADC and DAC not simultaneous
I am using stm32 g071 and what I have done in the code is to toggle pin and send the value through adc and finally output through dac. Theoretically, the GPIO output and DAC output should be simultaneous but due to processing time and all, there will be delay, however, in this case, this is inverted. Could anyone help me explain this behavior?
In the picture, the blue signal is from GPIO pin from MCU and red signal is the adc signal converted to dac.
void TIM2_IRQHandler(void)
{
if (TIM2->SR & TIM_SR_UIF)
{
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_6);
adc = HAL_ADC_GetValue(&hadc1);
DAC1->DHR12R1 = adc;
TIM2->SR = ~TIM_SR_UIF; /* Clear all interrupts */
}
}

