Skip to main content
MBertocchi
Associate II
November 19, 2021
Solved

Nucleo-L452RE-P ALTERNATIVE FUNCTIONS Timer Direct Mode - Gpio Output

  • November 19, 2021
  • 2 replies
  • 932 views

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?

This topic has been closed for replies.
Best answer by MBertocchi

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

2 replies

MBertocchi
MBertocchiAuthorBest answer
Associate II
November 19, 2021

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

TDK
Super User
November 19, 2021

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.

"If you feel a post has answered your question, please click ""Accept as Solution""."