For the GPS Tracker project I’ve been working on – struggling with, actually – getting all the communications subsystems working. I need to use UART for communication with the GSM module, soft UART (since the LPC11U24 has only one hardware UART port) for the GPS module and USB CDC for command and debugging.
And apart from the occasional programming blunders (like forgetting to increase a pointer when iterating elements in an array) I’ve had lots and lots of weird problems. But I finally got UART and soft UART working together and then I took a really long, hard look at the example USB CDC code I’ve been working with.
And it turned out that I needed to change a couple of things:
- The linker script (which should be for an LPC11U24 device) specified a RAM size of only 4 KB. This has been fixed to specify an SRAM size of 6 KB.
- The USB interface was initialized with a memory buffer at what was, in effect, an arbitrary place in the SRAM memory. The original code used
usb_param.mem_base = 0x10001000and
usb_param.mem_size = 0x1000.
For an LPC11U24, location 0x10001000 is at two thirds up in the SRAM area (which is from 0x1000000 to 0x10001800).
This has now been changed to use
usb_param.mem_base = 0x20004800and
usb_param.mem_size = 0x0800pointing to the top of the USB RAM area with a size of 2 KB (which is the size of the USB RAM).
USB_CDC_send()function calls the
WriteEPdirectly. This has been changed to copy data into a serial fifo buffer and calling
VCOM_bulk_in_hdlr()function when the USB host requests data. And the max packet size is also observed now.
And with these changes in place I was rewarded with the following session on the USB CDC terminal connection:
sys test OK - Response from SYS TEST sys version OK - b155 on 2012-09-02 13:34:17 +0200, git 31db1bb904695fc5347a136dbf2c819520162099 gps status OK - GPS status: 1, sats: 6/12, time: 121246.854, lat: 5538.7522N, lng: 01233.1385E
Next steps are getting the ADC working for monitoring the battery level and implementing the interface for the GSM module.