I am making a sound card with STM32H750 and USB3300. I am using standard Stm32CubeMX USB driver.
To do that, I need to track the number of I2S sample rate clocks per SOF. The idea is to use TIM5 as a counter, by supplying it an external clock via TIM5_ETR pin and resetting it using the internal ITR signal from USB.
I've successfully configured USB and it's SOF (the SOF handler is working), but for some reason the timer does not reset.
Here is the configuration code:
RCC->AHB4ENR |= RCC_AHB4ENR_GPIOAEN;
MODIFY_REG(GPIOA->MODER, GPIO_MODER_MODE4_Msk, 0b10 << GPIO_MODER_MODE4_Pos);
GPIOA->AFR[0] |= 2 << GPIO_AFRL_AFSEL4_Pos;
NVIC_SetPriority(TIM5_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 3, 2));
NVIC_EnableIRQ(TIM5_IRQn);
RCC->APB1LENR |= RCC_APB1LENR_TIM5EN;
TIM5->PSC = 256 - 1;
TIM5->ARR = 0xFFFFFFFF;
TIM5->CR1 |= TIM_CR1_ARPE;
TIM5->DIER |= TIM_DIER_UIE | TIM_DIER_TIE;
TIM5->SMCR |= TIM_SMCR_ECE;
TIM5->SMCR |= 0b01011 << TIM_SMCR_TS_Pos;
TIM5->SMCR |= 0b0100 << TIM_SMCR_SMS_Pos;
__DMB();
TIM5->CR1 |= TIM_CR1_CEN;
Also, for some reason, the USB HS description in the reference manual contradicts the timer internal trigger connections (it says that USB HS SOF is ITR1, not ITR7):
I've tried ITR1 as well - still does not work. Neither does the counter reset or the trigger interrupt being called.
What am I missing? Is there some USB HS configuration that needs to be done?