The backstory for what I'm trying to do:
I'm using an STM32H7 to monitor a quadrature encoder. Every X amount of ticks I want an interrupt to be thrown so I can send an external trigger pulse to a keysight DMM.
What I have working, is that the STM32 is monitoring the quadrature pulses on TIM1 and counting. I can pull this using i = TIM1->CNT; all day long. But it doesn't seem like it's attached to the IRQhandler properly so I can send out a pulse.
I did change HAL_TIM_Encoder_Start(&htim1,TIM_CHANNEL_ALL); to HAL_TIM_Encoder_Start_IT(&htim1,TIM_CHANNEL_ALL); but it only seems to be throwing TIM1_CC_IRQHandler which seems to ignore what I'm setting as the period.
From my understanding, what I should be able to do, is to specifiy a period of 1000, which means it should count up to 1000 and then trigger one of the IRQ handler functions to do it's thing. I did notice that the STM32CubeIDE didn't autogenerate a stub function for TIM1_IRQHandler(void).
int main(void)
{
long i;
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_ETH_Init();
MX_USART3_UART_Init();
MX_TIM1_Init();
MX_TIM3_Init();
MX_USB_DEVICE_Init();
quarterRevolutions = 0 ;
while (1)
{
i = TIM1->CNT;
}
}
static void MX_TIM1_Init(void)
{
TIM_Encoder_InitTypeDef sConfig = {0};
TIM_MasterConfigTypeDef sMasterConfig = {0};
htim1.Instance = TIM1;
htim1.Init.Prescaler = 0;
htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
htim1.Init.Period = 1000;
htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim1.Init.RepetitionCounter = 0;
htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
sConfig.EncoderMode = TIM_ENCODERMODE_TI12;
sConfig.IC1Polarity = TIM_ICPOLARITY_RISING;
sConfig.IC1Selection = TIM_ICSELECTION_DIRECTTI;
sConfig.IC1Prescaler = TIM_ICPSC_DIV1;
sConfig.IC1Filter = 5;
sConfig.IC2Polarity = TIM_ICPOLARITY_RISING;
sConfig.IC2Selection = TIM_ICSELECTION_DIRECTTI;
sConfig.IC2Prescaler = TIM_ICPSC_DIV1;
sConfig.IC2Filter = 5;
if (HAL_TIM_Encoder_Init(&htim1, &sConfig) != HAL_OK)
{
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterOutputTrigger2 = TIM_TRGO2_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) != HAL_OK)
{
Error_Handler();
}
HAL_TIM_Encoder_Start_IT(&htim1,TIM_CHANNEL_ALL);
}