Wednesday, September 20th 2017, 8:08pm UTC+2

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

jorick

Beginner

Date of registration: May 6th 2011

Posts: 7

1

Thursday, March 1st 2012, 11:44pm

Hard fault on LPC1788 when reading a byte

We’re getting a hard fault on our LPC1788 processor when executing an SVC #3 instruction after trying to read a character from the USB port after enumerating in CDC mode. The hard fault has only the Forced bit set. The SVC exception has a priority of 0 (the highest), and the processor is not in an exception when the hard fault occurs.

If enumeration is the only thing done, the firmware keeps running normally after the connection. But once an attempt is made to read a character from the USB port (I’m using the USB_CDC_ReceiveTimed function), the first SVC instruction encountered causes a hard fault. There is no data at the USB port when we call the read function.

I’ve traced through the function call to see what I/O was done in the USB device and came up with the following list:

0x00040500 -> 0x2008C210 Command | Read 1 byte from EP 4 -> USB Command Code
0x00000010 <- 0x2008C200 Read device interrupt status
0x00000010 -> 0x2008C208 CCEMPTY -> USB device interrupt clear
0x00000020 -> 0x2008C208 CDFULL -> USB device interrupt clear
0x00040200 -> 0x2008C210 Read -> USB command code
0x00000031 <- 0x2008C200 Read device interrupt status
0x00000010 -> 0x2008C208 CCEMPTY -> USB device interrupt clear
0x00000021 <- 0x2008C200 Read device interrupt status
0x00000000 <- 0x2008C214 USB command data

Testing shows that no USB interrupts occur after enumeration and during or after the read.

This post has been edited 1 times, last edit by "jorick" (Mar 1st 2012, 11:50pm)


jorick

Beginner

Date of registration: May 6th 2011

Posts: 7

2

Friday, March 2nd 2012, 9:21pm

Found it. Can't do a SVC call with interrupts disabled.

The documentation says that the OS layer wants a couple of functions that disable and enable interrupts. This doesn't work with SafeRTOS. I used portENTER_CRITICAL and portEXIT_CRITICAL instead. This leaves interrupts enabled but ensures that task switching doesn't occur within the critical section.