cancel
Showing results for 
Search instead for 
Did you mean: 

HardFault with USB CDC ??

matic
Associate III
Posted on July 21, 2016 at 20:32

Hi.

When I send data out via USB, the program goes to HardFault. I found out that this happens when the function below is executed:

USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev)
{
if(pdev->dev_state == USBD_STATE_CONFIGURED)
{
if(pdev->pClass->SOF != NULL)
{
pdev->pClass->SOF(pdev);
}
}
return USBD_OK;
}

This function is defined in usbd_core.c file. Has anyone an idea what could go wrong here? Thanks
3 REPLIES 3
Posted on July 21, 2016 at 21:10

Wouldn't it suggest thatpdev->pClass is NULL or at an inaccessible memory location? Or perhaps thatpdev->pClass->SOF isn't valid?

USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev)
{
if(pdev->dev_state == USBD_STATE_CONFIGURED)
{
if((pdev->pClass != NULL) && (pdev->pClass->SOF != NULL))
{
pdev->pClass->SOF(pdev);
}
}
return USBD_OK;
}

What does the Hard Fault state of the processor suggest is the problem?
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
matic
Associate III
Posted on July 22, 2016 at 07:51

Hi Clive.

When Fault occurs. IBUSERR bit is set in CFSR register. The fault occurs when this

pdev->pClass->SOF(pdev);

is executed. The SOF is not NULL at that moment. If you look to the attached picture, you can see the exact instruction where it faults. This is when BLX is executed.

________________

Attachments :

Capture.JPG : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtlX&d=%2Fa%2F0X0000000aWe%2FeEM7N61haXZXhzL3Qn7iw.gdKFfxUKXICAa3M7cflhw&asPdf=false
Posted on July 22, 2016 at 13:19

This really doesn't show the salient registers at the faulting instruction.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..