cancel
Showing results for 
Search instead for 
Did you mean: 

USB SOF interrupt not working :(

thln47
Associate III
Posted on February 01, 2016 at 13:37

Hi,

MCU : STM32F303RBT6

Library : STM32Cube_FW_F3_V1.4.0 ()

I want to use USB SOF (Start Of Frame) as 1ms timer to send usb datas.

With the old standard library, it's works perfectly.

So, I've set my function address inside the USBD_ClassTypeDef structure as described below.

The device is well recognized by the host, but the interrupt occurs only one time, then no more happens ...

Is something wrong in my code, or did I forget something ?

Thanks for reply

[code]

// Low layer callback

void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) {

    USBD_LL_SOF(hpcd->pData);

}

// my SOF function

uint8_t USBD_TMC_SOF(USBD_HandleTypeDef *pdev) {

    static uint32_t sof_counter = 0;

    if (sof_counter++>=5) {

        HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_8);

        sof_counter = 0;

    }

    return USBD_OK;

}

// structure

const USBD_ClassTypeDef USBD_TMC = {

    USBD_TMC_Init,

    USBD_TMC_DeInit,

    USBD_TMC_Setup,

    NULL,                 /*EP0_TxSent*/

    NULL,                 /*EP0_RxReady*/

    USBD_TMC_DataIn,         /*DataIn*/

    USBD_TMC_DataOut,        /*DataOut*/

    USBD_TMC_SOF,             /*SOF */

    NULL,

    NULL,

    USBD_TMC_ConfigDescriptor,

    USBD_TMC_ConfigDescriptor,

    USBD_TMC_ConfigDescriptor,

    NULL,

};

[/code]

#stm32-usb-sof
3 REPLIES 3
thln47
Associate III
Posted on February 01, 2016 at 14:39

Hi,

It's seems that SOF Interrupt enable is not set after a suspend/resume event!

Extrated code from stm32f3xx_hal_pcd.c (Line 583)

    /*set wInterrupt_Mask global variable*/

    wInterrupt_Mask = USB_CNTR_CTRM  | USB_CNTR_WKUPM | USB_CNTR_SUSPM | USB_CNTR_ERRM \

            | USB_CNTR_ESOFM | USB_CNTR_RESETM;

            

I've added USB_CNTR_SOFM flag, and it's works 🙂

    /*set wInterrupt_Mask global variable*/

    wInterrupt_Mask = USB_CNTR_CTRM  | USB_CNTR_WKUPM | USB_CNTR_SUSPM | USB_CNTR_ERRM \

            | USB_CNTR_SOFM | USB_CNTR_ESOFM | USB_CNTR_RESETM;
Walid FTITI_O
Senior II
Posted on February 04, 2016 at 10:36

Hi ln.thierry,

Thanks for your feedback and contribution. I will communicate this to our team.

-Hannibal-

Khouloud GARSI
Lead II
Posted on January 20, 2017 at 10:57

Hi 

,

Issue confirmed and corrected in version V1.7.0.

Thanks a lot for your contribution and sorry for any inconvenience this may have caused.

Khouloud.