2021-11-19 12:09 AM
Hi, I am experimenting with the Nucleo-L452RE-P the ALTERNATIVE FUNCTIONS of the PA6 pin, what I need is that the pin acquires a rising edge through the Timer Direct Mode generating INTERRUPT, this works correctly
void HAL_TIM_IC_CaptureCallback (TIM_HandleTypeDef * htim)
{
if (htim-> Channel == HAL_TIM_ACTIVE_CHANNEL_1)
{
}
}
subsequently it must become a GPIO Output keeping the output low and I do this correctly by configuring the pin in this way:
static GPIO_InitTypeDef GPIO_InitStructA = {0,0,0,0,0};
GPIO_InitStructA.Pin = GPIO_PIN_6;
GPIO_InitStructA.Mode = GPIO_MODE_OUTPUT_OD; // Open drain
GPIO_InitStructA.Pull = GPIO_NOPULL;
GPIO_InitStructA.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init (GPIOA, & GPIO_InitStructA);
HAL_GPIO_WritePin (GPIOA, GPIO_PIN_6, GPIO_PIN_RESET);
Now I just have to find a way to reset the GPIO PA6 as a Timer Direct Mode to wait for a new rising edge, what can I do?
Solved! Go to Solution.
2021-11-19 12:48 AM
I solved my problem I did not set the ALTERNATIVE PROPERTY
GPIO_InitStructA.Pin = GPIO_PIN_6;
GPIO_InitStructA.Mode = GPIO_MODE_AF_OD;
GPIO_InitStructA.Alternate = GPIO_AF2_TIM3;
HAL_GPIO_Init (GPIOA, & GPIO_InitStructA);
2021-11-19 12:48 AM
I solved my problem I did not set the ALTERNATIVE PROPERTY
GPIO_InitStructA.Pin = GPIO_PIN_6;
GPIO_InitStructA.Mode = GPIO_MODE_AF_OD;
GPIO_InitStructA.Alternate = GPIO_AF2_TIM3;
HAL_GPIO_Init (GPIOA, & GPIO_InitStructA);
2021-11-19 05:09 AM
You should also be setting the Speed attribute.
Thanks for following up with the solution. Please select your reply and choose "Select as Best" to mark the question answered.