Two of our most used microcontrollers (MPC555, MC68332) are currently programmed over the PC parallel port (LPT). Because this port does no longer exist in most notebooks and even in some desktop computers, the aim of this project was the develop a programming and debugging interface connected to USB.
For communication with the target microcontroller a Cypress FX2LP USB microcontroller is used. Because the FX2LP doesn't have a SPI, a memory mapped external Microwire/SPI Interface Device is used for efficient communication with the MPC555. As this allows only transfer sizes of 8/16 bit and the MC68x32 microcontroller supports only transfer sizes of exactly 17 bit per instruction, a SPI is emulated by I/O pins when communicating with the MC68x32.
![]() |
|
Board Functions
|
1. (LED green) The board is powered 2. (LED withe) The USB bus is powered by an external device 3. (LED blue) Freeze signal, if on the processor is in the debug mode and halted 4. (LED yellow) Status 2, must blink if interface processor is running 5. (LED yellow) Status 1, if on the USB bus is connected to a highspeed host, else to fullspeed host. |
6. (Jumper) Power for interface circuit is drawn from USB bus 7. (Jumper) Power for interface circuit is drawn from microcontroller board (only jumper 6 or 7 must be applied at the same time!) 8. (Jumper) Must be on 9. (Push button) The programming device can be reset |
The schematic can be downloaded here
The firmware source-code is in this svn-directory. To update the firmware on the interface-print follow these steps:
1. download and modify the source-code in eclipse
2. download and install the CyConsole Software (cy4604___usb_developer_s_ustudio_19.exe)
3. remove the jumper next to the serial-port
4. connect the debug interface to the computer
5. install the required drivers
6. start the CyConsole Software and open the EZ-USB-Interface (menu Options)
7. plug the jumper back
8. press the download-button and select/download the new firmware
The software provides the driver and library for the USB Programming and Debugging Interface print. Currently the Motorola MC68x32 and Motorola MPC555 are supported as target microcontrollers.
The PC software is based on the Java libusb / libusb-win32 wrapper project and the main communication and BDI (Background Debugging Interface) specific parts are implemented in Java.
Because the device must be accessed from BlackBox (Component Pascal), a JVM is started from a dll and the java methods are called through the dll (Java Native Interface). To write and read data from the Cypress FX2LP microcontroller, the JVM accesses the USB device driver (LibUsb-Win32) through another dll. This is a nice example to show how to combine different program parts in different programming languages using dlls on Windows. The following schematic gives an illustration of the design.

Communication between the host and the device over USB is packet oriented. This ensures flexibility and convenience in implementing new features.
Because USB is a host initiated bus, only the host (PC) can initiate data transfers (see USB in a NutShell for more information about USB). Due to this fact, the device always waits for a response after sending a data packet to the device (by definition). If no response is returned, a timeout exception is thrown. The request and response packet identifiers are defined in the dispatch.h file. Make sure the definitions on the host side (see ch.ntb.mcdp.usb.Dispatch for Main Types) correspond to the values defined in dispatch.h. The packet structure is shown in the following picture.

Note that the packet header and packet end identifiers are checked up on correctness in the dispatch methods (device and host). The packet length is limited by the USB transfer size and is 512 bytes in high speed mode and 64 bytes in full speed mode. All request/response data transfer is handled over one OUT and one IN endpoint. A separate IN endpoint is used for the UART data received from the microcontroller. The UART is usually used as logging output.
As mentioned in the „Hardware“ section an external Microwire/SPI Interface Device is used to efficiently communicate with the MPC555. To minimize the work for the Cypress USB microcontroller, BDI commands to the target (MPC555) are looped through the SPI interface without interpreting or changing it in any way. The result of the transaction is sent back to the host. For that reason the host is responsible for preparing the command and interpreting the result. The problem with this approach is, that a complete transaction takes the time consisting of two USB transfers (send command, receive result) and the time the microcontroller needs to process the command between the USB transfers. With large amount of data this can take a lot of time.
For large data transfers a more efficient method has been implemented. After using a start command and setting up a base address, as much data as fits into one USB packet can be sent to the USB microcontroller. It then sends the data in multiply transfers to the target and checks the result for error conditions. Only a success of failure response is sent back to the host. This allows fast transfers of a large amount of data.
The Windows installer which includes the LibUsb-Win32 device driver and the Java wrapper dll can be downloaded here. You need administrator privileges to install the software.