Programming a Microcontroller (ATtiny84) via SPI - Page 1
Forum section: electronics / general

author: selkathguy
author_rank: Unknown
timestamp: March 01, 2014, 03:18:14 pm
content: Kickers: It's over USB, through an FTDI (221X) Bridge, and the MCU has no bootloader.The FTDI 221X is working perfectly.Now,The ATtiny ships from the factory with SPI programming enabled.ATtiny84 CompleteIs it possible to program this device using only the USB, with the bridge in COM emulation mode? Every time I search for an answer to Programming the attiny over SPI, I get results involving the usage of a standalone programmer. I have an AVRDragon, BusPirate, etc, but there is no ISP header on my board (I assumed I could program through FTDI but I am doubting now). I'm starting to think I might have dun goofed here and will have to re-spin the board. Please advise. Thanks!EDIT: Scroll down for pictures of the board.EDIT:Schematics

author: fluxcapacitor
author_rank: Frequent Contributor
timestamp: March 01, 2014, 03:44:37 pm
content: ive got no experience programming an attiny84 but according to the ft prog user guide it should be possible through the virtual com port :http://www.ftdichip.com/Documents/AppNotes/AN_124_User_Guide_For_FT_PROG.pdf

author: dannyf
author_rank: Super Contributor
timestamp: March 01, 2014, 03:59:13 pm
content: QuoteAnything is possible: you could software emulate usb on it for example. But serial programming is pretty simple. so why bother?

author: TerminalJack505
author_rank: Super Contributor
timestamp: March 01, 2014, 04:00:55 pm
content: So you have an FTDI header on your board but not an ISP (SPI) header?So far as I know the FTDI header was meant to be used with MCUs that have a bootloader installed.Which pins of your MCU are the header pins going to? Maybe you can use the FTDI header with the Dragon using some kind of homemade adapter to get the signals to their necessary pins. (See page 163 of the datasheet.) This would allow you to use the Dragon and ISP serial programming.

author: selkathguy
author_rank: Unknown
timestamp: March 01, 2014, 04:36:55 pm
content: Quote from: dannyf on March 01, 2014, 03:59:13 pmBecause It's not directly serial programming. Its USB-> serial through a 221X, where the target device has no code on it whatsoever. Perhaps it still works the same way, I will try some more things today. I just wanted to be sure this has been done before. Most of what I hear is that these devices are programmed first, then placed in-circuit, or they have a header for a programmer to connect to directly communicate with the MCU. I have neither, all it is on my board is the FTDI hooked directly to the MCU like so:Schematics.Quote from: TerminalJack505 on March 01, 2014, 04:00:55 pmNo there is no FTDI header, just a footprint on the board to which the FTDI is attached, the traces run directly to it. See the PDF above,R5 is a required pull-up in theFT221X datasheet.

author: selkathguy
author_rank: Unknown
timestamp: March 01, 2014, 04:43:56 pm
content: Just for context, here's what it looks like physically:

author: TerminalJack505
author_rank: Super Contributor
timestamp: March 01, 2014, 05:02:02 pm
content: Oh, I see. That might work with arvdude if you set the programmer type to 'avrftdi' or 'ft232r.' I'm not familiar with either of them, though, so I'm not certain. Some further research would be required.

author: selkathguy
author_rank: Unknown
timestamp: March 01, 2014, 05:23:57 pm
content: Quote from: TerminalJack505 on March 01, 2014, 05:02:02 pmOh! alright I'll give that a shot when I get home. Everyone keeps saying that unless you have a bootloader you *must* use an AVR programmer, but that doesn't make sense to me, the chip has program commands built in, and the SPI programming interface is enabled by default, so I think it should be able to do it without a bootloader.

author: TerminalJack505
author_rank: Super Contributor
timestamp: March 01, 2014, 05:51:05 pm
content: The one thing that worries me from your schematic is how you have the MCU's reset pin wired-up. The programmer software is probably going want to control that pin (it holds it low during programming) and it doesn't look like it will be able to. You might have to manually control it.

author: Stonent
author_rank: Super Contributor
timestamp: March 01, 2014, 06:14:26 pm
content: Ft232 chips are usb to rs232 so that one may not work.

author: selkathguy
author_rank: Unknown
timestamp: March 01, 2014, 06:46:41 pm
content: Quote from: Stonent on March 01, 2014, 06:14:26 pmIt's an FT221X though. USB to SPI Bridge.http://www.ftdichip.com/Support/Documents/DataSheets/ICs/DS_FT221X.pdf

author: selkathguy
author_rank: Unknown
timestamp: March 01, 2014, 06:53:40 pm
content: Quote from: TerminalJack505 on March 01, 2014, 05:51:05 pmHow would the the program expect to be able to drive a pin via COM? I guess maybe if it was in Direct mode and not COM it could try to change the function of the CBUS pin on the FTDI, but I'm currently using CBUS to notify external circuitry (and power the ATtiny84) when the USB has negotiated for high-power. Yeah I expect to have to fiddle with the reset manually for now. I designed a tactile switch to go there, so if I need to program the device, I just plug it in while holding down the switch. Or at least that was the idea. A bit fiddly but I'm okay with that if it works.