Introduction to the FX2 USB Development Board CY7C68013A


Today we will take a look at the USB 2.0 Development Board assembled by Waveshare. It is based on Cypress FX2LP chip CY7C68013A (56-pin package) with the 8051 MCU, 16 kB RAM, 8/16-bit parallel bus, I2C, GPIF and USB 2.0 interfaces. There are three 8-bit I/O ports: A, B, D. 100-pin package has additional ports C and E, USART, three timers and etc.

Writing led blinking firmware

Keil uVision C51 is one of the best IDEs for MCS-51 firmware development. Another great development tool is IAR Embedded Workbench. GNU C/C++ does not support MCS-51 instruction set, but you can try to use SDCC free compiler. Now start your IDE and select “Project->New uVision Project…” menu item. Choose a folder for your project and type project name. Now you are ready to select the MCU. Keil uVision MCU Selection

Create new source file “main.c” and add it into the project. For successful linking you will need STARTUP.A51 assembler source file. It will be linked automatically from \Keil5\C51\LIB folder. The EZUSB.LIB file is required for more complex projects with USB support. It can be found in FX2LP SDK examples.

#include "fx2.h"
#include "fx2regs.h"

void Delay(volatile unsigned int i)
	while( i > 0 ) i--;

void main()
	// Enable output on Port_A (pins: 0, 1)
	OEA = 0x03;

	while( 1 )
		IOA = 0x00;    // All leds ON
		PA0 = 1;       // Led#0 at A0 off
		PA1 = 1;       // Led#1 at A1 off
		//IOA = 0x03;  // Both leds off

Use “Small” memory model and “Large” code ROM size. Turn-off code optimization. When you compile this project you will get “blink.hex” file in your \Objects folder. There are four options to download firmware into the Cypress FX2LP MCU. The firmware must be written to the on-board RAM and executed.

The first method is to use Cypress default drivers and transfer firmware into RAM with CyControl application (the source code is available). When you reset or power off the MCU the firmware will be erased. The second method (0xC2 option) is to store the firmware and the bootloader in the EEPROM permanently. Anyway you will need CyContol application from FX2LP SDK  to program the MCU.

Firmware download into Cypress FX2

Select “Cypress FX2LP No EEPROM Device” (or equivalent) and choose menu item “Program → FX2 → RAM”. Point to the “blink.hex” file and wait several seconds until you get the “Programming succeeded” message in the status bar. Now you should see blinking leds.

At power-on reset the FX2LP checks for EEPROM connected to its I2C bus and reads the value at address 0. For value 0xC0 the FX2LP automatically copies the VID, PID, DID from the EEPROM into internal RAM storage. The host OS loads corresponding driver and so it works. For value 0xC2 the FX2LP downloads firmware from EEPROM into RAM via bootloader. When your firmware is ready you can download it to EEPROM. You will have to convert your firmware from .hex into .iic file.

How to convert .HEX file to .IIC file

For EEPROM programming you will need .IIC file with I2C bootloader and your firmware code. There is a conversion utility HEX2BIX.EXE. It can be found in the FX2LP SDK folder:

Program Files\Cypress\USB\CY3684_EZ-USB_FX2LP_DVK\1.1\Bin\Hex2bix.exe

It can be used as a command line tool or as an after-build script in uVision IDE.

The command line parameters are:

  • -i option request .IIC file format;
  • -f 0xC2 sets the value for the first byte;
  • -o sets output file name.

Default Vendor ID is 0x0547 (Cypress semiconductor), Product ID 0x2131 (EZ-USB chip) and its driver “ezusb.sys”. The Vendor ID 0x0547 sometimes refers to Anchor Chips. This company was acquired by Cypress several years ago. One more compatible, digitally signed and useful driver from Cypress is: VID = 0x04B4, PID=0x1004 “Cypress FX2LP Sample Device” and the driver name is “cyusb3.sys”.

How to recover and reset VID/PID in EEPROM

Firmware development process is not easy. It requires lots of tests and many EEPROM programming. Making mistakes at work is good for learning and debugging. Sometimes you will make a brick from your FX2LP CY7C68013A board. If the device disappears from Device Manager do the following:

  1. 1. Disconnect the board from USB or turn-off the power cable.
  2. 2. Remove jumper (yellow) from SDA line.
  3. 3. Power on the device and find “Cypress FX2LP NO EEPROM Device”
  4. 4. Put the jumper, i.e. connect the SDA line.
  5. 5. Run “CyControl” utility and program EEPROM with any valid VID/PID (use myReset.iic from zip-file).
  6. 6. Wait for successful completion and reconnect/reset device.

Cypress EEPROM reset recover

I should say a few words about the jumper. If you take a look at the board schematic you will find that P_SDA jumper connects SDA and SDA_E lines. When the jumper is absent the AT24C164 (Serial EEPROM 16K) is not accessible by the MCU. In that case the MCU loads default VID/PID and does nothing.

There are many logic analyzers based on the FX2LP CY7C68013A chip. These devices store configuration in EEPROM. Before erasing or resetting your device make sure you have a valid firmware and configuration files.

Happy programming! Feel free to comment.

This entry was posted in Firmware and tagged , , , . Bookmark the permalink.

Leave a Reply