Go Down

Topic: Arduino Uno/Mega R4: Program with ICSP. (Read 82 times) previous topic - next topic

technix

Since we already have some way to use an Arduino, especially the Leonardo, as an ISP, is it possible to incorporate that code into the ATmega16U2 chip and make the 16U2 reprogram the 328P (Uno R4) or 2560 (Mega2560 R4) using ICSP instead of using the serial bootloader?

In this mode of operation, take the Uno R4 as an example, the 328P will not need a special bootloader. When programming is required the 16U2 will act like an ICSP programmer and reprogram the 328P over SPI ICSP. During normal operation the 16U2 will tri-state its ICSP pins to prevent it from interfering with the 328P. The 16U2 still functions like a USB to Serial adapter during normal operation so that existing sketches need not to be changed.

This will make the Uno R4 board accept any AVR that is pin compatible with 328P, make that board not only a electronics prototyping platform but also a more powerful AVR rescuing and programming tool. For Mega2560 boards with this design, an adventurous user can desolder the 2560 chip and add a ZIF socket to make it a similar tool to fix any chips pin compatible with the 2560 chip.

P.S. The LM358 can be eliminated by leveraging some more pins of the 16U2. The 16U2 can also output its 16MHz clock signal (using fuse settings) to the 328P, eliminating the crystal attached to the 328P.

CrossRoads

#1
Nov 10, 2014, 08:46 pm Last Edit: Nov 10, 2014, 08:46 pm by CrossRoads
R4 would be the next Rev?

There was another topic recently describing using the USB/Serial 16U2 to do ICSP programming of the 328P and 2560, so it's certainly possible. I don't know if you'd want it hardwired into the board (I'd prefer not, just to keep the SPI bus cleaner electrically) or just have a set of headers that a user could connect via 2-pin jumpers, or via a short 4-pin cable (Reset, MOSI, MISO, SCK) if routing between the 16U2 header and the ICSP header was an issue.

Quote
This will make the Uno R4 board accept any AVR that is pin compatible with 328P, make that board not only a electronics prototyping platform but also a more powerful AVR rescuing and programming tool.
The options there are all parts with less of all memory types. Check the data sheet. And generally not available at the cost savings one might expect for less memory. I suppose if one had a stock of the other chips handy.
ATmega48A; ATmega48PA; ATmega88A; ATmega88PA;
ATmega168A; ATmega168PA; ATmega328; ATmega328P
I didn't compare current prices. I don't generally do projects that need less capable parts; I suppose some of the simple LED clock display projects would be candidates. Not interested in stocking more chip types tho. Got enough to keep track of already!

Quote
For Mega2560 boards with this design, an adventurous user can desolder the 2560 chip and add a ZIF socket to make it a similar tool to fix any chips pin compatible with the 2560 chip
Don't think so - have you seen the price of 100-pin ZIF sockets? They are normally used in manufacturing environments and are priced accordingly. The female headers would also be in the way of soldering a socket in place. The options are also limited to parts with less memory, altho the cost savings are more in this case.
ATmega640/1280/2560
$11/$15/$16.72 at Digikey for example

I tried to layout a Mega sized board with a Mega on a pin adapter that could be dropped in to replace a blown 2560. Could get most signals connected and broken out, kept ending up with 2-3 that just couldn't be routed on 2 layer board and TQFP package.  Maybe 4 layer and leadless part could b e made to work, at higher 4-layed PCB cost. Finally went to standalone part instead.  I have the PCBs and a couple of 2560's in hand, not brave enough to try soldering one down tho. Those pins are really close!

What is your suggesting for replacing the analog function of the LM358 to control auto power switching with the 16U2?  That seems like it would only add delay and loss of power leading to unwanted resets.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

technix

To clean off the SPI bus when not programming and one cheap CD4066 on the board and switch them on only when ICSP is in action. 4 analog switches for 4 lines, just the right size. This consumes 1 extra pin on 16U2 though.

My stock of AVR chip includes only ATmega328P and ATtiny85, the most capable 28-pin and 8-pin PDIP AVRs though, to keep my count of models down in a manageable state.

If the LM358 is also handling power switching as well as L13 then I rest my case on that, although there exists clones that used a more sophisticated PMIC that can handle USB, Li-Po and wall wart all at the same time, including Li-Po charging.

Go Up