I am playing around with an optical encoder built into a linear drive motor. There is a wire that is described as "Home indicator, TTL, Active high".
I have connected it to PA4 on my Nucleo-F446RE (STM32), have set it to "GPIO_input" and have set the GPIO to "Pull down". I am trying to read the pin to check when it is high to see where "home" is, but am not getting any results. I assume it is high whenever the code is restarted, so whichever position it is in when the code starts, the home position is there. Is that assumption by any chance incorrect?
I am using a global interrupt timer, and have a simple if statement that changes a variable when the home position is activated. This code is put into the timer interrupt callback timer:
I have connected it to PA4 on my Nucleo-F446RE (STM32), have set it to "GPIO_input" and have set the GPIO to "Pull down". I am trying to read the pin to check when it is high to see where "home" is, but am not getting any results. I assume it is high whenever the code is restarted, so whichever position it is in when the code starts, the home position is there. Is that assumption by any chance incorrect?
I am using a global interrupt timer, and have a simple if statement that changes a variable when the home position is activated. This code is put into the timer interrupt callback timer:
C:
void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim)
{
counter = __HAL_TIM_GET_COUNTER(htim);
count = counter;
if (HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_4) == GPIO_PIN_SET)
{
home_indicator_state = 1;
HAL_GPIO_WritePin(LED_GPIO_PORT, LED_PIN, GPIO_PIN_SET);
}
}