Bit Banging SPI on Arduino’s FT232RL

Here’s that screenshot again – we’ll need it for the description.

Screenshot of the FT232RL SPI Bit Bang Tool
Fig 3 – The SPI Tool Screenshot (again)

The flow of this tool is similar to the previous tools – Find, Open, Configure, then start sending data. The clock speed has been changed from kHz to the actual value written to the baud register. Bit clock is 16x this value.

You’ll notice some changes in the center section. In addition to setting the baud clock or just ticking “Max CLK”, you’ll need to define the FT232 bits used for each lines and the polarity of each of your lines. Choosing the bits is pretty self-explanatory, and you can change the bits around to fit the board you are using. No checking is done for overlap so don’t choose the same bits for two signals!

Moving on to polarity: For some detailed info on SPI polarities, go check out the Wikipedia SPI page. Long story short, the “normal” SPI polarity starts a transaction with the !CS pin falling. Data is clocked into the device on each CLK rising edge and changed on the CLK falling edge. The data line goes high to indicate a 1.

However, the CS polarity can be inverted, the clock can be inverted – might as well make them all configurable. You configure polarity in the middle section by ticking the “Active Hi” checkboxes. For any signal that is ticked Active Hi, it’s “active” or “logic 1″ state is high. Otherwise, the active state is low. In other words, if CS falls at the beginning of a transaction then CS is considered Active Lo, or unchecked. If CS should rise at the beginning of a transaction then it is Active Hi. Let’s look at the case of $AA transmitted with both normal and inverse polarity.

Transmission of $AA with normal SPI polarity Transmission of $AA with all signals inverted

Fig 4 and Fig 5. Sending $AA normally (Left) and with all signals inverted (Right)

Sure, there’s no reason we had to invert the data lines other than for fun – but we did. So these pictures represent the transmission of the same byte ($AA – 1010 1010) in both normal mode, and with all signals inverted by using the check boxes.

On the left, you can see CS (Yellow) fall to start a transaction. Then, Data (Blue) is set to 1 and CLK (Purple) goes high. The inverse happens on the right hand scope shot: CS rises, Data is set low and CLK falls. Same transmission, opposite polarities on each line.

With this toolkit, you should be able to interface just about any SPI or shift register you may find. Define your polarities and run the SPI Setup. Make sure to re-run if you go changing polarities later.

Continued on Next Page…

This entry was posted in Hacks. Bookmark the permalink.

2 Responses to "Bit Banging SPI on Arduino’s FT232RL"

Leave a reply