Sonntag, 23. September 2012

libusb 1.0 for Pascal

This is a follow-up post to LibUSB for Pascal on 2012-07-15. I've now added header translations for the newer version libusb 1.0 (as well as its fork libusbx) including an object-oriented wrapper and a few examples to be used with Pascal.

Please find the source code in the libusb-1.0 branch at https://github.com/hansiglaser/pas-libusb.

Sonntag, 12. August 2012

NXP LPC11U14 and the LPCXpresso Board

The NXP LPC11xx series microcontrollers include an ARM Cortex-M0 CPU with SRAM, Flash and numerous peripherals. The low-cost LPCXpresso development board offers a debug adapter (JTAG, more precisely SWD) via USB. This is used with the Eclipse-based LPCXpresso IDE. Fortunately NXP offers it for Linux users too, even including the drivers for the debug connection.

After rapt contemplation I concluded, that most, if not all, of my ideas for nice projects require the connection to a PC. I prefer USB, so the LPC11Uxx microcontrollers including a USB 1.1 (12 MBit) device core come in handy.

NXP really tries to establish a community around their microcontrollers with forums and near-open-source software. The ARM Cortex-M0 MCUs are positioned as 8-bit and 16-bit MCU replacement. Therefore they have quite small packages (QFN33, LQFP48). The LPC1102 is sold in a WLCSP-16 package of which I've posted microscope images some time ago.

The low-cost LPCXpresso boards come without pin headers. I've added sockets, because its easier to connect wires to them.

One feature of these boards is that they can be used as debug adapter for custom boards. The connections from the debug adapter part to the device part of the board are layed out to holes for a 8x2 pin head with 100mil pitch. When delivered, the connection is made with small solder dots which can be removed using desoldering braid. I've added the pin head and put 8 jumpers on it to re-connect the on-board microcontroller.

One massive drawback of these microcontrollers is their extremley slow Flash memory. This gets even worse because it is (nearly) kept secret. The datasheet as well as the web page praise the fast operating frequency of 50 MHz. You have to dig deeply into the user manual to find a third-level section called "Flash memory access" describing a register called "Flash configuration register". Only the specific description of the two bits "Flash memory access time" reveals that wait-states (this word is avoided too) are required at higher frequencies. The maximum flash frequency is 20 MHz, so at the praised 50 MHz CPU frequency only every third cycle is an active one, effectively dividing the performance by three! Only the timers and other peripherals can utilize the higher clock frequency.

While ranting, nearly all ARM microcontrollers have slow flash and nearly all companies try to obscure that fact. Some microcontrollers try to speed up things using some kind of cache, others put loads of (fast) SRAM for code storage. It is still disappointing to be mucked around.

Montag, 16. Juli 2012

Control and communicate with a Cypress EZ-USB

When developing a device with the Cypress EZ-USB AN2131 microcontroller, eztool might come in handy. It is a command line tool to control and to communicate with these microcontrollers via USB. It can also communicate to any USB device in a custom user mode.

eztool offers a convenient command line interface. It uses Tcl as scripting language and command interpreter. Actually, every command you enter is implemented as a Tcl command (but written in Pascal and compiled in the executable). The Tcl programming language offers unlimited options to use, customize and automate eztool.

eztool prints a prompt at the screen which signals the current mode. To wait for the user input, GNU Readline is used. This offers comforable command line editing, history and auto-completion.

For each Tcl command and variable a dedicated manual page is provided.

Please find the source code at https://github.com/hansiglaser/eztool. It uses the Pascal OOP wrappers for GNU Readline, Tcl and LibUSB. Its device firmware is based on the EZ-USB firmware template.

Sonntag, 15. Juli 2012

EZ-USB Firmware Skeleton

Back in 2002 I developed my first evaluation board with the Cypress EZ-USB AN2131 microcontroller. Since then I developed several projects using this microcontroller. Each time a dedicated firmware was necessary.

In 2011 a student used one of my firmware projects to develop a firmware for the Keil ULink JTAG adapter, which also has an EZ-USB microcontroller. Unfortunately my firmware had a few files with unclear license conditions, so he re-implemented most files. His work was published as OpenULINK as part of the OpenOCD JTAG driver.

I used his improved firmware as starting point for the development of a firmware skeleton for the Cypress EZ-USB microcontroller. Please find the source code at https://github.com/hansiglaser/ezusb-firmware.

LibUSB for Pascal

libusb is a C library that gives applications easy access to USB devices. Many of my previous projects involving USB devices (e.g. the EZ-USB breakout board) use the libusb to communicate with it from the PC.

Since libusb is implemented in (plain) C, its headers had to be translated to be used with Pascal. I've also added an object-oriented wrapper. Please find the source code at https://github.com/hansiglaser/pas-libusb.

Mittwoch, 4. Juli 2012

TCL for Pascal

TCL (Tool Command Language) is a scripting language widely used as integrated scripting engine. Some time ago I wrote a tool to remote control an EZ-USB chip via USB (soon to be published). It offers a command line interface using GNU Readline and TCL.

Since TCL is implemented in (plain) C, its headers had to be translated to be used with Pascal. I've also added an object-oriented wrapper. Please find the source code at https://github.com/hansiglaser/pas-tcl.

Dienstag, 3. Juli 2012

GNU Readline for Pascal

The GNU Readline library is used to prompt the user for textual input at the terminal. It provides features like a history and completion. When you work at the terminal, e.g. with the bash shell, you are actually using Readline during typing and acquiring previous input lines from the history.

GNU Readline is implemented in (plain) C. To use it with Pascal, I've translated the C headers and added an object-oriented wrapper. Please find the source code at https://github.com/hansiglaser/pas-readline.