Programming an AVR from another AVR ?

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Does anyone programmed an AVR from another AVR ?

I will use a Tiny26 and a Mega8 in a project.
To minimize time and hazzle in production I plan to include to code for the Tiny26 in the code for the Mega8, and program the Tiny from the Mega.
Seems to be within reach.

Does someone has the C-code for this ? (I try not to invent the wheel again, so to speak.)

Tobias

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, that is how the STK500 and ATAVRISP do it, and the sample application in the Atmel app note (AVR910?) should be almost exactly what you need.

Lee

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've done it before for several projects. The source code is not open, so as much as I'd like to help I cannot share. I can tell you it's easy to do this function. You just need to have I/O lines for MOSI/MISO/SCK/RESET/Vcc/Gnd 6 lines total.

For a new project I am considering using AVR with self-Programming and write a boot loader to update firmware, thus eliminating the need for the RESET line. I may even try to get it to work through the TWI, and free one I/O line as well.

Regards,
Jeff

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Tobias,

Like Jeff I've done it also. And unfortunately with the same code restriction.

What I did was build a small module with dual SPI ports for programming (I used Atmel's 10 pin header format), and the uC on the board copies code from a master part to an unprogrammed part with a push of a button. This is used by our production people. Faster than using AVRISP and the like, and no PC required. I've programmed 4433s and Mega8s this way (the Mega 8 had some datasheet ambiguities that made this harder than it should have been).

I like your idea of programming the Tiny from the Mega. If you're doing any quantity of production, the folks on the line will like the time you're saving them not having to program as many parts. Just include a signature byte in your code that the Mega will check before programming so it won't program the Tiny unnecessarily.

Dennis

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Dennnis,

I'm planning to use the SPI port of the Mega8, and control the reset line of the Tiny26.

Why did you use an second SPI for the second uC ? Pinwise I cannot use a second SPI.

At start-up, I check an EEPROM location. If it reads 0x55 I know the second uC is programmed, otherwise I donwload the code, and then sets the EEPROM byte to 0x55.
Maby I add a bootloader, so updating code can be done on site. The unit already has a serial port.

Tobias