Simple LED Control via USBP Library

The following will outline how to control the 8 LEDS on the USBP FPGA Prototype board. This will use a simple bulk transfer to send data from PC to the FPGA board.

The quickest way to use the USBP library (at least on windows) is to download the latest install. The USBP.dll will exist in the install directory. Either copy the USBP.dll to the directory with your Python script or place your Python script in the install directory. I believe you could also add the USBP installed directory to your PATH.

Browse the API documentation for more information on the USBP library.

Python Script for the USBP FPGA Prototye Board

import time
import USBP
 
c = USBP.PBRD01()
c.initUSB()
 
err = c.loadFxFirmware('usbp_v1.hex') # Or latest Firmware
if err != 0:
    exit
time.sleep(2)   # Extra precaution for re-enumeration
 
err = c.configFPGA('led.bit') # Or latest Xilinx bit stream
if err != 0:
    exit
 
# Simply cycle the LEDs 
for q in range(1000):
    for i in range(255):
        c.xferFPGA(i)
        time.sleep(.100)

If the above code runs successfully the LEDs on the board should toggle as a binary count.

The code for the above example can be retrived from sourceforge. You can browse the SVN repository through the sourceforge webpages or check-out the latest code (directions here). The code is in the examples/usbp_simple_led directory.

The code in the example will include Python script, USBP library, FX2 8052 code, and the FPGA code.

If you have any problems getting this example to work please post you questions to the support forum

 
fpgaz/usbp/led1.txt · Last modified: 2007/03/27 16:24 by cfelton
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki