LPC1347 - Hard Fault closing COM port

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC1347 - Hard Fault closing COM port

361 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by BPC on Wed May 29 15:50:53 MST 2013
I am using the LPC1347 as a VCOM device (CDC) and having an issue with a hard fault upon closing the COM port.  Using PUTTY, I can open the port fine and see the data coming through.  But about 50% of the time, closing the port or closing PUTTY causes a hard fault.  I am using the ROM USB drivers.

Any ideas?
0 Kudos
Reply
4 Replies

333 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by BPC on Fri May 31 08:58:28 MST 2013
Ok better approach.  Instead of this guess work, I've changed my project MCU settings (which changes linker file) to reduce RamLoc8 size by 0x1000.  I then changed my USB allocations shown below.

usb_param.mem_base = 0x10001000;
usb_param.mem_size = 0x1000;

cdc_param.mem_base = usb_param.mem_base;
cdc_param.mem_size = usb_param.mem_size;

Now, there is no chance of "program" RAM, allocated at compile time,  interferring with USB RAM allocated at runtime.
0 Kudos
Reply

333 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by BPC on Thu May 30 08:46:46 MST 2013
Quick update / more questions.

After reading some posts, I noticed that the ROM_USB_cdc example uses the following settings:

usb_param.mem_base = 0x10001000;
usb_param.mem_size = 0x1000;

Looking at UM10524, shouldn't this be:

usb_param.mem_base = 0x20004000;
usb_param.mem_size = 0x0800;

Memory location 0x10001000 specifies the lower 4k of SRAM0??? I wonder why the example doesn't have this set to the 2kB USB SRAM as shown above.

Secondly, I also noticed in the example that:

cdc_param.mem_base = usb_param.mem_base;
cdc_param.mem_size = usb_param.mem_size;

Whereas app_usbd_cfg.h shows:

#define CDC_MEM_BASE           0x20000000
#define CDC_MEM_SIZE           0x00001000 <--this runs into "reserved" (i think size should be 0x800)

In summary, I have changed my code to these new values and the Hard Fault upon COM port closing has "gone away".  However, I noticed my responses to Set Line Coding were corrupt (i.e. instead of 9600bps, the response was 293874981734261 bps).

After some more reading, I've changed back to:

usb_param.mem_base = 0x10001000;
usb_param.mem_size = 0x1000;

which fixed the corrupt Line Coding responses and I've now changed to:

        cdc_param.mem_base = 0x20000000;
        cdc_param.mem_size = 0x0800; <--no longer goes into "reserved"

Seems like alot of trial and error to me, but Hard Faults are gone and Set Line Coding responses are correct.

If anyone can confirm this or point me in the right direction I would really appreciate it.
0 Kudos
Reply

333 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by BPC on Thu May 30 07:08:13 MST 2013
Hi Tsuneo,

My code is based on the LPCXpresso ROM CDC example.
0 Kudos
Reply

333 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Tsuneo on Thu May 30 02:28:36 MST 2013
Identify the subroutine and the cause of fault, following to this support note,
"Debugging a hard fault (Cortex-M4/M3/M0+/M0 based processors)"
http://support.code-red-tech.com/CodeRedWiki/DebugHardFault

Windows CDC driver, usbser.sys, puts Set_Control_Line_State( DTR:0 ) request to a CDC device, when a PC application closes a COM port using CloseHandle(). Your problem may be triggered by this request.

Anyway, where does the example code come from, LPCExpresso example folder, or LPCWare?

Tsuneo
0 Kudos
Reply