Hard Fault when processing USB class requests

Discussion created by lpcware Employee on Jun 15, 2016
Content originally posted in LPCWare by m-kondo on Thu Mar 28 04:26:02 MST 2013

I am trying to implement USB test & measurement class on my MCB4300 (LPC4357) board as device mode using KEIL RTL and RL-USB. But when after processing a class request in the usbd_cls_if_req() callback function, a Hard Fault is always generated.

Actually in the cls_if_req()function, a class request (device-to-host) comes, set up the out-going (EP0-IN) data stage, then calls USBD_DataInStage() finishing with __TRUE return. The data stage is actually sent back to the host only at the first time, but after returning from usbd_cls_if_req(), a Hard Fault will be generated inside USB_CM.lib. Both USB0(HS) and USB1(FS) generate this problem.

As for std requests, there is no probrem at all, but as soon as returning a data-stage from inside usbd_cls_if_req(), the program falls into Hard Fault. I also tried exactly the same approach with MCBSTM32F400 (STM32F407) board and there was no such problem.

Can anybody please help me?

Makoto Kondo