Author Topic: Arduino program upload  (Read 3921 times)

0 Members and 1 Guest are viewing this topic.

Offline DzAnejTopic starter

  • Contributor
  • Posts: 24
  • Country: si
Arduino program upload
« on: January 30, 2017, 01:49:00 pm »
Hi
I'm working on a remote control project using an Arduino. I will be using the Atmega328p (au - smd version) and I'm not quite sure how I'm going to upload the sketch to the IC...
How many different ways are there to program an Arduino (SPI, I2C, Serial, ...)?
And because the IC is new, the bootloader probably won't be installed aswell. So which pins should I make accessible for programming?
 

Offline alexanderbrevig

  • Frequent Contributor
  • **
  • Posts: 706
  • Country: no
  • Musician, developer and EE hobbyist
    • alexanderbrevig.com
Re: Arduino program upload
« Reply #1 on: January 30, 2017, 01:59:07 pm »
You need the ICSP (In Circuit System Programming) header:


Now you can use Atmel Studio to upload the bootlader. After that you can upload from the IDE if you have an FTDI cable, and a header to plug into:
https://cdn.sparkfun.com/datasheets/Dev/Arduino/Boards/Arduino-Pro-Mini-v14.pdf
« Last Edit: January 30, 2017, 02:02:36 pm by alexanderbrevig »
 
The following users thanked this post: DzAnej

Offline obiwanjacobi

  • Super Contributor
  • ***
  • Posts: 1030
  • Country: nl
  • What's this yippee-yayoh pin you talk about!?
    • Marctronix Blog
Wrong code should not compile!
 

Online Buriedcode

  • Super Contributor
  • ***
  • Posts: 1953
  • Country: gb
Re: Arduino program upload
« Reply #3 on: January 30, 2017, 02:32:20 pm »
If you have an Arduino UNO handy, there is an example sketch that allows this to program blank Atmega's.  But the USBasp is a worthwhile investment for 'unbricking' AVR's.

I believe the Arduino bootloader hex is in the Arduino directory, so this would need to be flashed, and the fuse bits set.  I shunned Arduino for many years, but now pretty much all of my Atmega's have an Arduino bootloader on them now for the sheer convenience.
 

Offline DzAnejTopic starter

  • Contributor
  • Posts: 24
  • Country: si
Re: Arduino program upload
« Reply #4 on: January 31, 2017, 08:36:30 pm »
Ok, I've connected MISO, MOSI, 5V and GND. Next, the SCK pin is pin 17 in my case and RST is connected to RESET (pin 29)?
 

Offline sleemanj

  • Super Contributor
  • ***
  • Posts: 3176
  • Country: nz
  • Professional tightwad.
    • The electronics hobby components I sell.
Re: Arduino program upload
« Reply #5 on: January 31, 2017, 08:44:18 pm »
Yes.

FWIW, here is the "Arduino Pinout" for the 328, this is a simplified diagram I made because I think the fancy diagrams are too busy, this just has what most people need.

~~~
EEVBlog Members - get yourself 10% discount off all my electronic components for sale just use the Buy Direct links and use Coupon Code "eevblog" during checkout.  Shipping from New Zealand, international orders welcome :-)
 
The following users thanked this post: DzAnej

Offline rrinker

  • Super Contributor
  • ***
  • Posts: 2046
  • Country: us
Re: Arduino program upload
« Reply #6 on: January 31, 2017, 08:45:13 pm »
 There is also the ArduinoISP sketch which turns the Arduino into an ISP programmer - not swapping the chip for a blank one and programming it, but using a working Arduino to program various Atmel micros. I went all out and built the full version with indicator LEDs configured for ATTiny (I have a project that will use many ATTiny 85's) with an 8 pin socket and said indicator LEDs on a home made shield. I may do another one with a 28 pin ZIF socket to program ATMega 328's, as I was going to just use Nanos in my other project because they are so cheap and it's no big deal to put in pin headers so the Nano can be removed from the board for programming or replacement, but PDIP ATMegas328's are even cheaper.
 
 Here's one such link for building an ISP shield. This one doesn't have the activity LEDs but you can google that. Or look at the ArduinoISP sketch, you can see in addition tot he lines used for the actual ISP to the blank chip, it also has 3 output pins for the status LEDs.

https://learn.adafruit.com/arduino-tips-tricks-and-techniques/arduinoisp

 

Offline Rick Law

  • Super Contributor
  • ***
  • Posts: 3538
  • Country: us
Re: Arduino program upload
« Reply #7 on: February 01, 2017, 10:27:10 pm »
Hi
I'm working on a remote control project using an Arduino. I will be using the Atmega328p (au - smd version) and I'm not quite sure how I'm going to upload the sketch to the IC...
How many different ways are there to program an Arduino (SPI, I2C, Serial, ...)?
And because the IC is new, the bootloader probably won't be installed aswell. So which pins should I make accessible for programming?


Are you doing Arduino without an Arduino board?  In other words, you are going to hook up the MCU yourself so it emulate an Arduino board with your IC?

That is certainly not a problem.  I have a couple of ATMEGA328p-pu running that way.  I do need to match the Digital/Analog pins aligned with the way Arduino has them.  In my case, my naked 328p thinks it is an UNO.

But the NANO is so cheap it saves a lot of work...  Comes bootloader loaded and ready to go.

If you have an Arduino UNO handy, there is an example sketch that allows this to program blank Atmega's.  But the USBasp is a worthwhile investment for 'unbricking' AVR's.

I believe the Arduino bootloader hex is in the Arduino directory, so this would need to be flashed, and the fuse bits set.  I shunned Arduino for many years, but now pretty much all of my Atmega's have an Arduino bootloader on them now for the sheer convenience.

It doesn't have to be an UNO.  The Ardunio NANO will also work.  The pin layout is different (such as where is a certain Pin) but as long as you plug it into the right arduino-pin number, ArduinoISP will work nicely.  The NANO has all the pins UNO has except D0/D1 instead it has RX/TX and additional A6/A7 that UNO doesn't have.

The Ardunio Nano is so cheap (under $3USD) I dedicate one only to be my ISP Programmer so it is always handy.

As to fuse setting, Arduino has a list.  You can find the right fuse setting under:
[arduino directory]\hardware\arduino\boards.txt
Since > 1.6.1, boards.txt might have moved.

Look for text "high_fuses" and "low_fuse" and you will find the fuse setting section.
 
So, fuse setting may depends on if you want your 328p to run like it is in a nano (or whatever), you can find that in boards.txt.  The MCU match is what is necessary.  Other things (defaultBaud/clock/etc) may different between boards for the same MCU.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->