Pages: [1]   Go Down
Author Topic: Uploading a skectch into atmega328 that has uno bootloader and is in circuit  (Read 1636 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,
I managed to burn Uno bootloader into a plain atmega using the my Arduino Mega1280 and the arduino as isp tutorial. Now I have a gadget were the arduino is located and would like to upload sketches using the Uno board. Am I wrong or shouldn't this be possible by just removing the atmega from the uno board and connecting reset, tx,rx,+5,GND to the chip that is on the gadget.

I think this would be a pretty easy way to get the code into the gadget.

Any ideas?

Best Regards,

Tomas
ps Images are nice so I atached a picture of my RGB led light prototype.


* ArduinoRGBLedLight.jpg (169.55 KB, 1280x956 - viewed 33 times.)
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17292
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Now I have a gadget were the arduino is located and would like to upload sketches using the Uno board. Am I wrong or shouldn't this be possible by just removing the atmega from the uno board and connecting reset, tx,rx,+5,GND to the chip that is on the gadget.

I think this would be a pretty easy way to get the code into the gadget.

Yes, it is that simple and should work fine. Even simpler is to just plug a jumper wire between ground and the reset pin on your UNO. That will hold the chip in reset mode, but still leave the tx,rx,+5, and ground pins free to wire to your standalone UNO chip.

Lefty

Logged

Portland, OR
Offline Offline
Sr. Member
****
Karma: 7
Posts: 260
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm thinking what you guys are describing is, e.g., the breadboard circuit in this tutorial (with arduino pin 10 to reset, and pins 11, 12, and 13 the serial programming pins) am I right?:
http://arduino.cc/en/Tutorial/ArduinoISP

If so... I'm a little confused on what exactly is happening differently (in context of Arduino-as-ISP) between writing programs to the chip on the Arduino board vs. writing programs to the external chip?
I'm guessing it's related to Reset... what precisely is the function of reset here?

Based on what I've understood, reset serves to trigger the microcontroller to re-initialize, thus be open to (with the original bootloader still in place) new uploads, or if nothing is incoming, just lets it re-run the existent program in its memory. So, when @retrolefty suggested grounding the Reset pin on the arduino while loading programs to an external chip, what does that do?
(Reset is active low based on datasheet, so I understand somewhat...)
Logged

Scotland
Online Online
Edison Member
*
Karma: 25
Posts: 1308
Have you had your Arduino fix today?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

To upload to your standalone :
(ard - Arduino & std - stand alone)

ard rx - std tx
ard tx - std rx
+5 to +5
gnd to gnd

no power on std
short ard reset to ard gnd

remember to select the type of chip you are uploading to
click upload on IDE
wait for sketch size
tap std reset quickly

Drew.
« Last Edit: March 17, 2011, 06:52:54 am by spycatcher2k » Logged

Drew.
http://www.uk-pcb.co.uk - My UK Based PCB Fab & Assembly Company
Design work undertaken
SMD & Thru-Hole assembly

Gatineau, Qu
Offline Offline
Jr. Member
**
Karma: 1
Posts: 94
Did you Arduino today?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Now I have a gadget were the arduino is located and would like to upload sketches using the Uno board. Am I wrong or shouldn't this be possible by just removing the atmega from the uno board and connecting reset, tx,rx,+5,GND to the chip that is on the gadget.

I think this would be a pretty easy way to get the code into the gadget.

Yes, it is that simple and should work fine. Even simpler is to just plug a jumper wire between ground and the reset pin on your UNO. That will hold the chip in reset mode, but still leave the tx,rx,+5, and ground pins free to wire to your standalone UNO chip.

Lefty

From my experience you also need a jumper wire from the Uno board reset to the reset pin of the stand alone chip. So leaving the chip in with a jumper from between GND and reset wouldn't work. I take the chip off the board. But like I say ....... that's my experience! Maybe I'm just about to learn a simper way of doing this?

I'm thinking what you guys are describing is, e.g., the breadboard circuit in this tutorial (with arduino pin 10 to reset, and pins 11, 12, and 13 the serial programming pins) am I right?:
http://arduino.cc/en/Tutorial/ArduinoISP

No it's not.

It's more like this http://arduino.cc/en/Tutorial/ArduinoToBreadboard Look at the Uploading Using an Arduino Board section.

You take the Arduino as ISP to put the bootloader on the chip.
After the chip as a bootloader on it you don't need an ISP anymore (that's why you can put stuff on the chip on the Uno board without needing another board.)

So when you have an external chip with a bootloader. You put your sketch on it the same way you put it on your board. Except it's not ON the board, it's off the board with a couple of jumpers....so the Arduino IDE doesn't know it's off the board.......and it doesn't care!
« Last Edit: March 17, 2011, 07:35:37 am by alparent » Logged

Gatineau, Qu
Offline Offline
Jr. Member
**
Karma: 1
Posts: 94
Did you Arduino today?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

click upload on IDE
wait for sketch size
tap std reset quickly

OK, so this is how you guys are doing it!


But by jumping the 2 resets together I just let the IDE reset when it needs to reset.

You just gave me an idea! What if I cut the RESET-EN trace and replace it with a 2 pin male header.
When I want the board to act normally I just put a jumper connecting the 2 pins of the RESET-EN.
When I want to load stuff to and external chip. I remove that jumper, connect a jumper to the live side of the RESET-EN and to the reset pin of the external chip. And also put a jumper between the board reset and GND to desable the on board chip.

This should work! No?
Logged

Scotland
Online Online
Edison Member
*
Karma: 25
Posts: 1308
Have you had your Arduino fix today?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

you can do it by reset - reset, but you have to remove the arduino's chip for this to work.

I have built a MAX232 based lead for programming, and all my 'off board' projects have a 10 way box header (only 5 pins used). I've also built an 'AVR as ISP' based programming board with a zif  socket
to program bootloaders (and programs without the bootloader).

I buy blank chips in bulk (50s and 100s) - got a buyer for bootloaded chips, so that helps with the price.
There is also 3 of us that are 'into' arduino in the house, and we tend to build, document and keep our projects.


Drew.
Logged

Drew.
http://www.uk-pcb.co.uk - My UK Based PCB Fab & Assembly Company
Design work undertaken
SMD & Thru-Hole assembly

Portland, OR
Offline Offline
Sr. Member
****
Karma: 7
Posts: 260
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Cool, so what exactly is happening exactly when I did the following?

--I left arduino's atmega on the arduino just as it is, throughout the following steps...
--insert standalone atmega on breadboard
--connect up the circuit as shown in ArduinoToBreadboard tutorial (i.e., with SCK, MISO, and MOSI pins of arduino and of standalone atmega chip connected to each other)
--reset pin of standalone atmega chip (datasheet pin #1) with pull-up resistor, as well as a cable to pin #10 of Arduino (which is used in the ArduinoISP sketch for slave reset)
--arduino reset pin never handled by me (i.e., left open)

--I loaded ArduinoISP sketch to arduino
--burn bootloader using ArduinoIDE's Tools > Burn Bootloader command.
--then use AVRdude to load a hex file, e.g. avrdude -c avrisp -p m328p -P com3 -U flash:w:Blink.cpp.hex

The visible result is that everything worked fine... the Blink program is indeed uploaded, as I checked by placing an LED on standalone atmega chip.

But is there anything wrong with this approach of uploading code to the standalone chip? (i.e., with Arduino's atmega chip and reset pin left untouched, and shorting MOSI, MISO, and SCK pins between Arduino and standalone atmega chip)
I guess my question is...
What is the difference between that approach VERSUS the other approach discussed in this thread (i.e. where we first remove the Arduino Atmega chip from the board and ground Arduino's reset pin and then upload to standalone chip via ArduinoIDE/AVRdude with the RX and TX pins cross-connected?
« Last Edit: March 18, 2011, 01:59:44 am by giantsfan3 » Logged

Scotland
Online Online
Edison Member
*
Karma: 25
Posts: 1308
Have you had your Arduino fix today?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

hi, when u upload blink with avrdude, it overwrites the bootloader, so you need to 'isp' it if you want to upgrade your sketch. Using Rx and Tx, it is using the bootloader. Easy to upgrade.



Drew.
Logged

Drew.
http://www.uk-pcb.co.uk - My UK Based PCB Fab & Assembly Company
Design work undertaken
SMD & Thru-Hole assembly

Portland, OR
Offline Offline
Sr. Member
****
Karma: 7
Posts: 260
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

this works super well for me, spycatcher2k. although the timing of tapping the standalone atmega chip's reset has to be really on the mark!

Question:
what could be a way we can make this self-controlled? so that you can keep the atmega chip on the arduino ISP and still not have to manually mess with the standalone atmega chip's reset wire each time to be programmed.


To upload to your standalone :
(ard - Arduino & std - stand alone)

ard rx - std tx
ard tx - std rx
+5 to +5
gnd to gnd

no power on std
short ard reset to ard gnd

remember to select the type of chip you are uploading to
click upload on IDE
wait for sketch size
tap std reset quickly

Drew.
Logged

Scotland
Online Online
Edison Member
*
Karma: 25
Posts: 1308
Have you had your Arduino fix today?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Not without building custom circuits - e.g. max232 based serial programmer, with Dtr hooked up to reset through a cap.

Drew
Logged

Drew.
http://www.uk-pcb.co.uk - My UK Based PCB Fab & Assembly Company
Design work undertaken
SMD & Thru-Hole assembly

Pages: [1]   Go Up
Jump to: