Thursday, March 10, 2011

UART to USB converter using LPC1768 and AVR 8-bit UART library

While working on a project on the Atmega8 for school, the FT232 chip being used as a UART - USB converter failed. Well, actually its the board that failed, or rather broke...

Without a spare, my team tried to plough on without the very helpful debugging messages, but to no avail. It would take days for a new order to reach us. So, with the VCOM library I had recently prepared, using the LPC1768 as as USB to UART bridge became the best choice. It took only a few minutes to compile this firmware. If someone else is in the same plight, this should help you out and save some time re-inventing the wheel.

The latest binary file is here. It accepts data from the VCOM port and simply passes that to UART1 at the specified baud rate and any data received from UART1 is forwarded to the VCOM port. The baud rate can be adjusted in the terminal software/ device manager in the computer.

The first time the device is plugged in, you'll have to install a driver in windows. The required .inf file may be found here or in the source. If you want to improve the source into something more than the minimalistic implementation of mine, then here it is. You might have to change the PINCONFIG depending on which pins are used for UART1 if you are using something other than NGX LPC1768-H Blueboard.

Use this if you are using NXP USB secondary bootloader.

If you're using windows 7, then you'll have to employ a third party Serial Terminal. My favorite is TeraTerm.

And if you are interested, have a look at my rather eccentric UART library.

2 comments:

  1. Hi, first thanks for this code! I make it work on a RDB1768 board, but I can't redirect to /dev/ttyACM0 a file bigger the the rxfifo buffer. If I do this the BulkOut function is called a couple of times and, almost, the last two calls enter in the may not fit condition. After this the functino is not called anymore. I guess that the problem is that the USBHwEPRead function is not being called, since if I add it to the condition cited above the BulkOut continue to get called, but if I do this I lost data. Increase the buffer is not a solution for me too, since I can't increase them to the size of files that I need to redirect. I'm trying to realize what I can change to correct this for the last two days, but can't think of anything. There is anything on top of your head that could solve this problem?

    ReplyDelete
  2. I use win7 with RealTerm. There is an option wherein a preset delay is inserted between characters sent. Setting it something like 1 mS will ensure that buffer on LPC does not overflow.

    ReplyDelete