Skip to main content
Tim Schuerewegen
Associate
September 1, 2019
Question

HAL_PCD_EP_Open without HAL_PCD_EP_Receive can result in a hard fault

  • September 1, 2019
  • 0 replies
  • 601 views

The HAL_PCD_EP_Open function configures an out endpoint so that the host can actually write data to it, which is kind of a problem because if you did not use HAL_PCD_EP_Receive then ep->xfer_buff is NULL and USB_ReadPMA will generate a hard fault :(

To fix it I changed

PCD_SET_EP_RX_STATUS(USBx, ep->num, USB_EP_RX_VALID);

to

PCD_SET_EP_RX_STATUS(USBx, ep->num, USB_EP_RX_NAK); // was USB_EP_RX_VALID

in

HAL_StatusTypeDef USB_ActivateEndpoint(USB_TypeDef *USBx, USB_EPTypeDef *ep)

I am using STM32Cube_FW_F1_V1.8.0.

This topic has been closed for replies.