|
|
|
By openschemes, on October 25th, 2011% 5,109 views

Howdy Schemers,
We had to put the Digital Photoframe Projects on the shelf for a little while as we took care of some important business. It seems that a popular PowerPC has some problems with a very thin reset pulse. So thin that it’s often considered a reset glitch instead of a reset pulse. Oh Noes! You guys gotta take better care of your reset logic next time. Another valuable lesson learned.
Now while we don’t care one bit about how this glitcher works or what it’s used for, it is certainly interesting that the CPLD has exploded in popularity and is programmed exclusively using JTAG. Today’s lesson consists of the development of a bit-banged JTAG SVF player in order to program a device such as a CPLD. It’s quite likely that the SVF player we develop today could program an FPGA or flash a micro or some other good stuff we haven’t thought of yet – SVF is a very powerful data format. But at the moment, we’re going to stick to the task at hand – flash a bitstream to a CPLD using a homebrew JTAG interface. Our interface will use the synchronous bit-bang mode of the FT232 chip, as has been previously described in: Bit Banging SPI on Arduino’s FT232 and Lattice CPLD programmer using FT232. So let’s get to the program.
CPLD is Win
The CPLD board we’ll use for development today is the Digilent C-MOD board. This board is based upon the Xilinx XC2C64A CPLD. A CPLD (Complex Programmable Logic Device) is a programmable logic chip, smaller and a bit more streamlined than an FPGA but still fairly closely related. CPLD’s are mostly used as glue logic, or to implement smaller custom logic blocks in large designs.
CPLD’s are cool, and a worthwhile technology to have in hand because it’s REALLY nice to be able to implement a wee bit o’ custom logic without pinning out two hundred something FPGA pins. In the reset pulse tester mentioned earlier, the CPLD watches a few lines for a start of a known routine and begins shooting little reset pulses after a variable delay. If no problem is detected, the CPU is restarted with a little longer delay next time. Overall, the delay is swept over a wide range to make sure your CPU is not susceptible to the reset glitch problem.
It seems that all over the world, concerned citizens are taking it upon themselves to ensure their CPU’s are not problematic. We’re very proud to see so many non-g33k types take such an interest in supporting robust logic design, especially in the usually ignored categories of brownout and short pulse protection. Kudos! It seems that pretty much any board with an XC2C64A has been flying off the shelves, often into the hands of an average joe who simply isn’t interested in the headaches (read: FUN) associated with home bringup of programmable logic.
A common complaint is that folks are buying the CMOD or other compatible boards without having a programmer handy. Darn! The second most common (or related) complaint is that most PC’s manufactured after 1985 don’t have a parallel port. That’s an unfortunate situation, having a fancy new toy and not being able to twiddle around with it.
We decided that it’s time to lower the barrier to entry on homebrew JTAG’ing Xilinx chips, and the best way to do that would be to take that stupid LPT wiggler and send it back to hell where it came from. You want bit banging, you want USB convenience, and you want your programming jig to supply power to the target device. Done, done, and done. FT232.
Notice we said FT232, NOT FT2232. That is +FT232 -FT2232 in googspeak and please don’t even ask if a 2232 version is in the works. There’s a million projects that use the pre-packaged MPSSE mode of FT2232 to do all sorts of stuff way cooler than this. This article is taking it back to the old school, and bringing a JTAG SVF player to the good old fashioned synchronous bit bang chip available on every arduino board on the planet.
What’s in store for you today? You will learn how to traverse the standard JTAG TAP state machine in software, how to read and interpret the SVF file format, and how to churn data from your PC’s cozy USB port to the cold world of JTAG serial port using handcrafted square waves.
Jump to Page 2
By openschemes, on October 25th, 2011%
By openschemes, on June 17th, 2011% 2,299 views
 Just a quick one today, folks. Start to finish this should take ya 20 minutes, assuming 15 of them is trying to figure out where the hell your Sparkfun board is.
This is a wiring diagram for connecting the Sparkfun FT232RL Breakout Board (see our other posts on this device) to an SN75176 RS-488 bus transceiver. This simple combination gives you a homebrew USB DMX interface with just a couple of wires and a $0.69 logic chip from TI. It’s self-contained and USB powered – no muss, no fuss. You can buy the transciever chip and also a female XLR connector ($2.25!) from Jameco – these guys don’t suck, and they send cool catalogs. Plus, they once stayed open late so we . . . → Read More: Homebrew USB DMX Interface with Sparkfun FT232RL
By openschemes, on June 17th, 2011%
By openschemes, on September 8th, 2010% 4,083 views

Welcome back, schemers!
If you’re just arriving, then here’s a little background on the current project: We’re creating a remote-controlled relay board to switch on and off power to the Western Digital WDTV. In part one of the project, we designed and built a printed circuit board containing the hardware for the project. In this part, we will discuss the source code for the PIC micro that acts as the brains of the operation.
The WDTV remote uses the NEC infrared protocol at 38kHz to transmit commands to the WDTV. This 38kHz stream of blinks is demodulated by the IR receiver to a relatively slow serial datastream which is then piped to the PIC. An example of an NEC datastream is shown below, and was borrowed from here, FYI. There’s a billion different pages on the NEC IR protocol, but this one is kind of nice because all the timings are shown as well as clear differentiation between 1 and 0 states.

Fig 1 – Annotated Example of NEC IR Format
One thing to remember is that the output of the IR module is open-collector. So when you see a logic high in the above waveform, the PIC is actually going to be reading a 0. We’ll refer to this state as MARK, and to the inactive state as SPACE to avoid confusion.
To start out with, our code can simply loop away idly, looking for the input pin to drop from 5v (space) to 0v (mark). At that point, we’re interested. We will first check this leading pulse to make sure it’s about 9mS long, give or take about 10-20% to account for timing variations in the PIC internal oscillator as well as whatever crappy osc is used in the actual remote. If the data stays at mark for 9mS and then goes to space for 4.5mS – we’ve got data!
The NEC stream consists of 4 8-bit bytes. Well, two bytes actually – but they are repeated in normal and inverse mode so it’s best to just read in all 32 bits and then do our deciphering internally. The first two bytes are the device (address) and it’s inverse, and the next two are the command and it’s inverse.
A bit is represented by one mark pulse and one space pulse, and the duration of the space pulse determines whether the bit is a 1 or a 0. Specifically, 565uS of mark followed by 565uS of space signifies a 0. And 565uS of mark followed by 1.685mS of space signifies a 1. So really, once we’re convinced that we’ve got data all we need to do is measure 32 space pulses and set the corresponding bits in our data reg high and low.
That’s pretty simple, so NEC must now complicate matters. If a button is held down on the remote the main command will be sent once, followed by a “repeat” command sent every 109mS. This repeat command consists of the same 9mS of mark used as a start pulse followed by 2.25mS of space and a single 565uS mark.

Fig 2 – NEC Protocol in Repeat
So here’s the (software) scheme.
- Sit around waiting for the start sequence
- Decode 32 bits of data
- If it’s a power cmd, then turn on WDTV if it’s off. Go back to #1
- If WDTV is on and we receive a power command, flag that we now need to wait for 10 repeats. Go back to #1
- If WDTV is on and we’re repeating, watch for 10 repeats and then turn off WDTV.
- If some other command comes in, clear our “repeat” counter and start the whole thing over
Continued on Next Page Jump to Page 2
By openschemes, on September 8th, 2010%
|
Recent Comments