I bought a USBtinyISP programmer from adafruit. I know how to program microcontrollers, but how do I program external EEPROM (like AT25320 ) using the USBtinyISP?
Thanks
how to program an external EEPROM
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: how to program an external EEPROM
Hmm.. interesting question. I don't know if it's even possible to program a AT25320 with an ISP.
The AT25320 is an SPI device, and while an ISP uses SPI to program a microcontroller, the signals the programmer generates are tailored to the uC in question. To program an AT25320, you'd need the READ and WRITE commands listed in its datasheet.
If you want a piece of dedicated hardware to do the job, the Bus Pirate would be more the tool you need: http://www.adafruit.com/products/237 . Its whole purpose is to translate commands from your computer into messages in various protocols (SPI among them).
You don't really need that though.. any Arduino can do the job. The ATmega328 has built-in hardware to support SPI communication, so it can read and write data to the AT25320 all by itself. A Trinket would be able to handle the communication, but might not be able to hold all the information you want to write into the EEPROM.
The AT25320 is an SPI device, and while an ISP uses SPI to program a microcontroller, the signals the programmer generates are tailored to the uC in question. To program an AT25320, you'd need the READ and WRITE commands listed in its datasheet.
If you want a piece of dedicated hardware to do the job, the Bus Pirate would be more the tool you need: http://www.adafruit.com/products/237 . Its whole purpose is to translate commands from your computer into messages in various protocols (SPI among them).
You don't really need that though.. any Arduino can do the job. The ATmega328 has built-in hardware to support SPI communication, so it can read and write data to the AT25320 all by itself. A Trinket would be able to handle the communication, but might not be able to hold all the information you want to write into the EEPROM.
-
- Posts: 1
- Joined: Sun Oct 27, 2013 12:43 pm
Re: how to program an external EEPROM
I just found that you can use the USBtinyISP to input image into the external EEPROM on the SpokePOV kit, just wondering how you did that?
-
- Posts: 20
- Joined: Mon Jun 03, 2013 11:06 pm
Re: how to program an external EEPROM
yea, i wonder how they manage to store image into EEPROM using USBtinyISP
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: how to program an external EEPROM
Okay, I dug through the tutorials a little and found that you can use the USBtinyISP as a generic SPI interface. You have to look at the file usbtiny.c in the avrdude source code to really see what's going on though:
The generic SPI interface is implemented this way:
It's not quite bit-banging the SPI connection, but it's close.
There are more highly optimized read/write routines for programming entire pages of an AVR's memory, but that code seems to be AVR-specific.
So.. while it is possible to program an EEPROM using just the USPtinyISP, I stand by my previous statement that the job would be easier with an Arduino or Bus Pirate.
The generic SPI interface is implemented this way:
Code: Select all
/* Send a 4-byte SPI command to the USBtinyISP for execution
This procedure is used by higher-level Avrdude procedures */
static int usbtiny_cmd(PROGRAMMER * pgm, unsigned char cmd[4], unsigned char res[4])
{
int nbytes;
// Make sure its empty so we don't read previous calls if it fails
memset(res, '\0', 4 );
nbytes = usb_in( pgm, USBTINY_SPI,
(cmd[1] << 8) | cmd[0], // convert to 16-bit words
(cmd[3] << 8) | cmd[2], // "
res, 4, 8 * PDATA(pgm)->sck_period );
if (nbytes < 0)
return -1;
check_retries(pgm, "SPI command");
if (verbose > 1) {
// print out the data we sent and received
fprintf(stderr, "CMD: [%02x %02x %02x %02x] [%02x %02x %02x %02x]\n",
cmd[0], cmd[1], cmd[2], cmd[3],
res[0], res[1], res[2], res[3] );
}
return ((nbytes == 4) && // should have read 4 bytes
res[2] == cmd[1]); // AVR's do a delayed-echo thing
}
There are more highly optimized read/write routines for programming entire pages of an AVR's memory, but that code seems to be AVR-specific.
So.. while it is possible to program an EEPROM using just the USPtinyISP, I stand by my previous statement that the job would be easier with an Arduino or Bus Pirate.
Please be positive and constructive with your questions and comments.