10 years, 4 months ago.

PC serial conflicts with LCD on LPC1768

Hi:

I am using LPC1768 on the mbed Application Board. When I enable the LCD panel using:

C12832_LCD lcd;

All of my printf and puts get displayed onto the LCD panel instead of the USB COM port. Why is that?

The PC serial port is critical for me to debug my code. How do I make it always available?

Thanks! T.H.

3 Answers

10 years, 4 months ago.

I have no conflicts doing this. Are using the Serial API over the USBTX/USBRX pins? Something like the following:

    Serial pc(USBTX, USBRX);

    pc.printf("mbed app board!");

I've not shown it, but I have the LCD working in the same application.

Accepted Answer
T.H. Lu
poster
10 years, 4 months ago.

Hi David:

Thanks a lot of the feedback! Using the Serial class solved the problem. I can now use both LCD and the COM port for debugging.

However, I am still confused about this. I was using printf, scanf, and puts function calls directly before, without declaring the Serial API. However, I am sure the serial interface is working through the USB interface because I only have the USB cable connected. I had to install the mbed Windows serial port driver first to get it working. That method worked until I enabled the LCD interface. So how does the plain printf, scanf work in LPC1768? I don't think there is a physical pin conflict, because the serial interface is going through the USB.

Thanks!

10 years, 4 months ago.

Are you using the latest version of the library, the current one has code set to do it automatically, but it is commented out, so it shouldn't happen.

That or you might have it in your own code accidently. The library has code to be able to redirect all your standard printf messages to it. Sometimes that is handy, sometimes you don't want it. This is done by lcd.claim(stdout). If that is in your code, that is the one responsible for it.

But looking at your post I think you should update your library (click on it, then there is an update button). It imo isn't generally nice for libraries to do this implicitly, and apparantly someone agreed, because the last commit was:

Quote:

Don't claim stdout by default. Make the user of the library do that.

So if you have the last version it should work without claiming stdout.

You are right. I have a very old version of the C12832_lcd library. Once I updated it, my code works as expected. Now lcd.printf goes to the LCD, and regular printf goes to the serial interface as expected. My problem is solved. Thank you very much!

posted by T.H. Lu 01 Feb 2014