USB Programming and Debugging Interface

USB Programming and Debugging Interface

Introduction

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.

Hardware

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.

Software

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 Protocol

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.

Background Debugging Interface (BDI)

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.

Download and Installation

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.

FAQs

1. Installation
1.1. I'm getting an unsatisfied link error.
2. USB
2.1. I'm getting an USBException "USB device with idVendor 0x8235 and idProduct 0x100 not found".
3. MPC555 / MC68332
3.1. The MPC555 / MC68332 does not run code from flash at power up.
3.2. When plugging in the interface print, the MPC555 / MC68332 enters debug mode immediately.
1. Installation
1.1. I'm getting an unsatisfied link error.
1.1.

I'm getting an unsatisfied link error.

 

Make sure the LibusbJava.dll is in the Windows system32 directory (or on the java classpath). This should have been done by the installer. So make sure, the program is installed correctly.

2. USB
2.1. I'm getting an USBException "USB device with idVendor 0x8235 and idProduct 0x100 not found".
2.1.

I'm getting an USBException "USB device with idVendor 0x8235 and idProduct 0x100 not found".

 

Make sure the device is connected to the USB bus. To check if the device is properly installed, go to the Windows Device Manager. The device must be listed under "LibUSB-Win32 Devices" -> "Programming and Debugging Interface". If an unknown device is shown, try to reinstall the driver. The driver will be found automatically.

3. MPC555 / MC68332
3.1. The MPC555 / MC68332 does not run code from flash at power up.
3.2. When plugging in the interface print, the MPC555 / MC68332 enters debug mode immediately.
3.1.

The MPC555 / MC68332 does not run code from flash at power up.

 

The MC68332 needs a different electrical setup than the MPC555. As the MPC555 is the main target processor, the default setting (switch array: 0000) will allow the MPC555 to run code from flash at power up, but not the MC68332. This may be changed by setting the switch array to 1000 (set switch 1, don't set switch 2 to 4).

Note that the interface print must be powered to recognize the switch settings. If it is not powered, the MPC555 will work, but the MC68332 will not run at all. After changing the switch settings the interface print must be power cycled.

3.2.

When plugging in the interface print, the MPC555 / MC68332 enters debug mode immediately.

 

Same as last question.

 Reference: http://inf.ntb.ch/infoportal/help/index.jsp?topic=/ch.ntb.infoportal/projects.html

你可能感兴趣的:(windows,Flash,UP,pascal,Motorola)