DEV Community

Cover image for FTDI Bitbanging GCC
Thomas Brittain
Thomas Brittain

Posted on • Originally published at ladvien.com

FTDI Bitbanging GCC

This is a short note on how to setup a C programming environment for the FTDI chip in bit banging mode, since that's what I had difficulty doing.

There may be easier ways to go about this, but I wanted to use GCC to compile a small C program to control the 8 IOs. The purpose was to write a small command-line program that would reset my LPC1114 before and after programming.

To setup the environment:

  1. I downloaded and setup MinGW32.

  2. I then downloaded FTD2XX libraries. This included the ftd2xx.h file and ftd2xx.lib.

  3. I then stole the test code from Hack-a-Day's article on bitbanging with the FTDI.

  4. I modified the code as they suggested by including, in this order, the Windows compatibility files:

#include <stdio.h>
#include <stdarg.h>
#include <windows.h>
#include <windef.h>
#include <winnt.h>
#include <winbase.h>
#include <string.h>
#include <math.h>
#include "ftd2xx.h"
Enter fullscreen mode Exit fullscreen mode
  1. I then used the rest of their code as a base: Hack-a-Day's FTDI PWM Code

I used this line to build it:

gcc -o ftdi_PWM ftdi_Test.c -L./ -lftd2xx
Enter fullscreen mode Exit fullscreen mode

You must have both the ftd2xx.h and ftd2xx.lib in the same directory as you attempt to build.

  1. I then wrote two programs, one to send DTR and CTS high and low in order to reset the LPC1114 into programming mode. ** Second, to send DTR and CTS high and low in order to send the LPC1114 into **run program mode. The idea being, I could use the typical Sparkfun FTDI programmer to program my LPC1114.

  2. LPC1114_reset_to_program

  3. LPC1114_reset_to_bootloader

That's it. Just wanted to make sure this was out in the universe for the next guy's sake.

Top comments (0)