Arduino program upload - Page 1
Forum section: electronics / general

author: DzAnej
author_rank: Contributor
timestamp: January 30, 2017, 01:49:00 pm
content: HiI'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?

author: alexanderbrevig
author_rank: Frequent Contributor
timestamp: January 30, 2017, 01:59:07 pm
content: 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

author: obiwanjacobi
author_rank: Super Contributor
timestamp: January 30, 2017, 02:00:03 pm
content: + thishttp://www.ebay.com/itm/USBASP-USBISP-AVR-Programmer-Adapter-10-Pin-Cable-USB-ATMEGA8-ATMEGA128-Arduino-/310506909410?hash=item484ba76ee2:g:ZWQAAOSw-KFXehMl

author: Buriedcode
author_rank: Super Contributor
timestamp: January 30, 2017, 02:32:20 pm
content: 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.

author: DzAnej
author_rank: Contributor
timestamp: January 31, 2017, 08:36:30 pm
content: 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)?

author: sleemanj
author_rank: Super Contributor
timestamp: January 31, 2017, 08:44:18 pm
content: 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.

author: rrinker
author_rank: Super Contributor
timestamp: January 31, 2017, 08:45:13 pm
content: 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

author: Rick Law
author_rank: Super Contributor
timestamp: February 01, 2017, 10:27:10 pm
content: Quote from: DzAnej on January 30, 2017, 01:49:00 pmAre 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.Quote from: Buriedcode on January 30, 2017, 02:32:20 pmIt 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.txtSince > 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.