CrossRoads:
“Anyway, the point is that it should be ultra-easy to make an ICSP out of the FTDI chip”
That’s how I used to bootload 328P chips:
http://www.geocities.jp/arduino_diecimila/bootloader/index_en.html
Was a slow process. Dropped if for a USB ASP programmer after not too many chips.
And then Atmel AVR ISP MKii when I started playing with Atmel Studio and 1284P chips.
I’ve also got (several) “genuine” Atmel MK-II programmers. I just figured making one out of an FTDI breakout board would be a fun brain exercise.
The FTDI in bit-bang mode is very slow… IF you send one byte at a time because of the overhead of the USB communications protocol. However, the FTDI is capable of sending a burst of up to 64 bytes, so what I do is build up a packet of bit patterns, then burst it to the FTDI all in one shot. Here’s a piece of the code that does the burst:
// low level bit banger FTDI->VFD
void displayWrite (uint8_t dat, uint8_t reg)
{
uint8_t buf[64]; // buffer for bit patterns
uint8_t bits;
uint8_t cmd = 0b11111000; // serial command byte skeleton
uint8_t c = (SISO | STB | SCK); // initially set all pins high
uint8_t idx;
uint16_t data;
reg ? cmd |= RS_BIT : cmd &= ~RS_BIT; // select cmd/data
data = ((cmd << 8) | dat); // build 16 bit command word
idx = 0; // init index
c &= ~STB; // assert strobe (low)
buf[idx++] = c; // copy to buffer
bits = 16; // 16 bit command word
while (bits--) { // write out bits
c &= ~SCK; // lower sck
buf[idx++] = c; // copy to buffer
data &_BV (bits) ? c |= SISO : c &= ~SISO; // write a bit
buf[idx++] = c; // copy to buffer
c |= SCK; // raise sck
buf[idx++] = c; // copy to buffer
}
c |= STB; // de-assert strobe (high)
buf[idx++] = c; // copy to buffer
ftdi_write_data (&ftdic, buf, idx); // write out buffer
}
At first I was just and-ing and or-ing to each “buf[idx++]” and it wasn’t working. I finally transferred the code to a test program (Linux console mode) and did a dump of each byte. I realized that I needed a “shadow” byte (the var “c” in the code) to maintain the last bit pattern and then MODIFY the bit pattern as needed and copy it to the buffer.
Then I put the fixed code back into the Arduino side and taa-daa! It worked!
In fact, when sending single bytes, I can actually watch the characters appear on the VFD display (looks like an old 1200 baud modem), but in burst mode I actually have to set the FTDI baud rate to 9600 to slow it down or else the VFD can’t handle it!
The FTDI chip also has an 8 bit “parallel port mode” (not as in printer, but as in one byte at a time). I was using a Sparkfun FTDI breakout board that doesn’t break out ALL the pins, so I’ve got a couple cheap-o ones on order from Amazon that have all the pins broken out.
Can’t wait to see how that works! 