cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 USB Device configurate without USB interrupter

SDFSDFDSF
Associate II

 CubeMX generated a example for USB CDC, and with HAL_PCD_IRQHandler.

Now I want use polling method to initial USB,and communicate with host without USB interrupt.

So how can I modify it?

I had tried to do something ,but it not work.Please help me.

1.  disable USB interrupt at HAL_PCD_Start().

     

HAL_StatusTypeDef HAL_PCD_Start(PCD_HandleTypeDef *hpcd)

{

USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;

 

__HAL_LOCK(hpcd);

 

if (((USBx->GUSBCFG & USB_OTG_GUSBCFG_PHYSEL) != 0U) &&

(hpcd->Init.battery_charging_enable == 1U))

{

/* Enable USB Transceiver */

USBx->GCCFG |= USB_OTG_GCCFG_PWRDWN;

}

 

// __HAL_PCD_ENABLE(hpcd);

(void)USB_DevConnect(hpcd->Instance);

__HAL_UNLOCK(hpcd);

 

return HAL_OK;

}

 

2. moved out HAL_PCD_IRQHandler function to main loop.

 

but it dose not work.

when host send get descriptor,device dose not response.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Pavel A.
Evangelist III

Don't use/disable the timer thing for now, leave only the USB in the loop. Maybe, remove the battery charging thing too.  Will it work? Will it at least pass thru reset, assignment of address and at least one descriptor request?

 

View solution in original post

6 REPLIES 6
TDK
Guru

You could poll for USB IRQ flags and call the handler when they're active, but that seems silly. What's the purpose of removing interrupts?

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

We have a Timer interrupt and priority is very high, the interrupt time is 100us.we do not want usb interrupt disturb it.

I had tried the method like you said.But when the host send get descriptor command, device wasn't response.

> We have a Timer interrupt and priority is very high, the interrupt time is 100us.we do not want usb interrupt disturb it.

Set the USB interrupt to be lower priority (numerically higher) than your timer priority.

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

Don't use/disable the timer thing for now, leave only the USB in the loop. Maybe, remove the battery charging thing too.  Will it work? Will it at least pass thru reset, assignment of address and at least one descriptor request?

 

I will try what you said.

USB reset status can be received.but descriptor is not.

Then the USB data lines may be in problem. Get a physical USB bus analyzer or scope.