project: Bolt v.Lite handles the USB port with simple ANSI C functions.



This project was originally developed by Microchip for its Demo board PICDEM FSUSB for the 18F4550 microcontroller.

The project includes a Windows PC VC++ test software, and the firmware for the microcontroller board, with complete C18 files for the USB stack and the so called USB-UART functions  to easily program the USB port in ANSI C, as if it were a serial port.

Some changes were  made to the project source code firmware program and to the linker script for compatibility with Bolt 18F2550 system hardware and bootloader firmware.

Reading of the next document is strongly recommended before procceding to the testing of project: MIGRATING FROM SERIAL PORT TO USB.pdf




One of the features of the 18F2550 microcontroller is having an embedded USB port, which makes it possible to design PC peripherals -as for example, bar code readers or RFID scanners- based on boards like the Bolt 18F2550 or Bolt v.Lite.

However, handling the USB port either from a Windows PC software application or from the microcontroller itself was traditionaly a complex task, given that the USB port operates with a multilayer high level protocol.

On the contrary, on the serial port, sending and receiving ASCII codes and strings, using a low level communications protocol, is rather easy, and there are already many applications developed for remote control from the PC to the microcontroller target.

This project describes how to handle the USB communication using the Bolt 18F2550 system, emulating a serial port with minimal changes over existing projects. Both, the source code for the application PC software and the firmware for the 18F2550 microcontroller are provided so that the user may make changes and adaptations to his own requirements.

Thanks to the fact that the USB handles the details of low level communications, the baud rate, parity bit or flow control parameters used in the tradicional RS232 interface, become an abstract reference. The standard speed of this USB interface is 80 Kbytes per second.


Based on the diagram shown above, the project has 2 parts: the firmware for the 18F2550 microcontroller, and the software for the PC. Both programs interact through the USB port to achieve simple functions: to detect the change of state in microswitch SW1 of Bolt v.Lite, and to echo the text characters the user sends (using the PC program), adding +1 to each received ASCII code.

Firmware: this firmware for the 18F2550 must be loaded in Bolt v.Lite board using the software Bolt 1.0.1. The executable .hex file is: BOLT-18F2550-USB.hex. The firmware includes the complete USB stack, which is a multilayer protocol, and the so called USB-UART functions, which considerably simplify the ANSI C programming, and permits the user the handling of the USB port in the same manner a serial port would be. Source program of firmware is available.

PC Windows Microchip driver: all Windows systems have in their libraries, the drives to manage the USB conection of the PC, emulating a serial COM port. When you connect the Bolt v.Lite (loaded with the firmware described in the paragraph above) system to the PC, the OS automatically installs this driver (plug and play).

VC++ PC software: the project includes an application that works through a virtual COM serial port, using the driver described above. Once the PC and the Bolt 18F2550 are connected through the USB cable, the user may execute the PC software and a window will open (please see diagram on top of page). The user may the make 2 tests: toggling SW1 in the microcontroller target will be detected by the software with the text: "Button Pressed -". User also may write any text in the window (i.e. "GNK@") and click on the Send Data button. The microcontroller will receive the message, then add a +1 to every ASCII code and echo the whole message back. In this example, the user will see an "HOLA" in the application window.





Click here for more information on the handling of the USB STACK