10 years, 5 months ago.  This question has been closed. Reason: OK, now with what Erik and Carl added, I understand. Thanks all!.

printf to USB serial for debugging

So, it seems Elektor publishers were overstocked with LPC11U24s, because they were offering these as an incentive for subscription renewal. So, I ended up with one of these.

For some time I have been thinking of making a small midi file player, with the thought that I might then extend it to flash some lights, or maybe animate one or more of those toys that seem to come out at this time of year as Christmas approaches. I was considering something like the ETT STM32 board, like this http://www.futurlec.com/STM32_Development_Board.shtml, with the midi files on a SD card.

Now I am wondering if the LPC11U24 could be persuaded to do something like this. With that I could dispense with the SD card and put the files, which are not very big, on the Local File System. It would be a bit of a challenge with only 8K of RAM, particularly to support "format 1" (multi-track) midi files, but I decided to have a go.

So I lifted up a midi file player program and tried to cram it into the LPC11U24. I ran into some trouble but one of the main problems at the moment is that I cannot get printf debugging messages to work through USB serial. I read the SerialPC page, https://mbed.org/handbook/SerialPC, but I still have no luck. I have installed the required Windows driver, and that works because I get output from other example programs, and even from other small programs of mine, but for my midi file playing program I get nothing. The program sails past various printf statements as if they are not there. I put one right after the entry point of main, and I still see nothing, so it does not appear to be something that the program does while running that breaks it, but rather something it contains, or does not contain, or something???

Any suggestions about how to find why printf does not work for this one program?

I'm getting tired of flashing out messages in code on the leds.

3 Answers

10 years, 5 months ago.

Same answer as similar question that was asked today: the lpc11u24 has only one physical serial port / uart. The last one you declare gets the port. That will probably be your MIDI outputport. You could try the usb interface for debugging to the pc instead. Alternative is to develop a software serial port that does some bitbanging on a portpin.

Accepted Answer
Andy Wood
poster
10 years, 5 months ago.

Wim,

Many thanks for that. I already saw the other question, but did not understand it was the same problem I had. I had seen that there was only one uart, but did not get that the serial output sent via USB somehow also needs to use that uart.

You are definitely right though. I pulled out the Serial used for the midi out for a test, and magically all the printf output appears. Of course, I have no midi output now, but still it should help me to figure out where it is going wrong.

I don't quite understand your suggestion to "try the usb interface for debugging to the pc instead", since I thought that was what I was trying to do in the first place. Obviously not, so I'm still having some trouble with the basic terminology here.

An understandable confusion. Wim meant for you to use the LPC11u24s USB capability, the USB port is connected to an interface chip. However the LPC11u24 also has USB capability, via the D+ and D- pins, you only need to connect a USB connector to it. Then you can using http://mbed.org/handbook/USBSerial send Serial messages also over USB.

posted by Erik - 16 Nov 2013
10 years, 5 months ago.

LPC11U24 has built in USB, you can use this to enumerate as a CDC USB ( Serial over usb ) but you will need the USB Device library inlcuded in your project.

The DipCortex M0 is similar ( It uses the LPC11U24 ) to the mbed I have an example for it here :

Import programDipCortex-USB-CDC

Create a UART to USB Serial bridge with the DipCortex

This uses the USBDevice library.