Go Down

Topic: Program an Atmega8 on a PCB (Read 528 times) previous topic - next topic

LastSamurai

Hi,

I am not really sure if this is the right part of the forum for this. If not please change ;)

I designed my own pcb with an atmega8 on it. There is also a connector with the MISO, MOSI, SCK, RESET Pins and Ground + VCC of the board. I can programm the Atmega on a breadboard using the arduino uno + the arduinoISP sketch no problem, but my goal is to programm the chip right on the board.
How do I do that? Do I only need to connect MISO,MOSI, SCK and reset to the uno's pins or also VCC and Ground? Does the boards own power needs to be connected?

spycatcher2k

This all depends on YOUR layout - Impossible to say - but if you do power the board, just don't connect VCC from the UNO.
Drew.
http://www.uk-pcb.co.uk - My UK Based PCB Fab & Assembly Company
Design work undertaken
SMD & Thru-Hole assembly

LastSamurai

#2
May 05, 2014, 06:22 pm Last Edit: May 05, 2014, 06:28 pm by LastSamurai Reason: 1
Ok, thanks. I simply connected the pins from the atmega8 to the pin header. Does the rest even matter?
What's the "normal" way this is done?

pico

#3
May 05, 2014, 06:47 pm Last Edit: May 05, 2014, 07:00 pm by pico Reason: 1

Ok, thanks. I simply connected the pins from the atmega8 to the pin header. Does the rest even matter?
What's the "normal" way this is done?


You have to provide power to the chip to program it. Investing in a simple ISP programmer such as a USBasp or the USBtinyISP (nor expensive) will allow you to connect and program while the chip is on the board via the 6 pin ICSP header (stands for in-circuit serial programming, which is what you want to do).

Usually the ISP programmer will power the chip via the header while the programming is taking place. You control the ISP programmer via avrdude from your PC.

WiFi shields/Yun too expensive? Embeddedcoolness.com is now selling the RFXduino nRF24L01+ <-> TCP/IP Linux gateway: Simpler, more affordable, and even more powerful wireless Internet connectivity for *all* your Arduino projects! (nRF24L01+ shield and dev board kits available too.)

CrossRoads

Use the ICSP pins - SCK, MISO, MOSI, Reset, Gnd, Power - to program a bootloader onto the board.
Then use a USB/Serial adapter - such as FTDI Basic - connected to Rx, Tx, Gnd, DTR thru a 0.1uF cap to Reset, Power, to download sketches.
USB interface will also let you debug via Serial.print statements. ICSP does not do that.
Easy way is to have a header for both.
Less easy way is to connect to the IO pins with a breakout cable to the FTDI Basic or ICSP programmer.
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.

pico


Less easy way is to connect to the IO pins with a breakout cable to the FTDI Basic or ICSP programmer.


It sounds like he already has the 6-pin ICSP header on the board. No?
WiFi shields/Yun too expensive? Embeddedcoolness.com is now selling the RFXduino nRF24L01+ <-> TCP/IP Linux gateway: Simpler, more affordable, and even more powerful wireless Internet connectivity for *all* your Arduino projects! (nRF24L01+ shield and dev board kits available too.)

LastSamurai

I have the ICSP header (MOSI,MISO,SCK,Reset, GND, VCC) on the board. But you can only use this to upload a bootloader?
But I do use the exact same pins to program it via arduino uno (isp)?!

What do I then need the RXD and TXD pins for (besides serial communication)?

PS @pico: I do not own a USBasp or something like that but the arduino with the ISP sketch does the exact same thing, doesn't it?

pico

#7
May 05, 2014, 07:35 pm Last Edit: May 05, 2014, 07:40 pm by pico Reason: 1

I have the ICSP header (MOSI,MISO,SCK,Reset, GND, VCC) on the board. But you can only use this to upload a bootloader?


No, you can use it for any program. In fact, when you are using it to program the bootloader, the bootloader is just like any other program.


But I do use the exact same pins to program it via arduino uno (isp)?!


yes, the SPI pins, plus Vcc, Gnd, Reset.


What do I then need the RXD and TXD pins for (besides serial communication)?


You don't need them at all for ISP programming. They are only used by the bootloader to program if you have a bootloader loaded on the chip.


PS @pico: I do not own a USBasp or something like that but the arduino with the ISP sketch does the exact same thing, doesn't it?


Yes, but much less conveniently. You were asking what the "normal" way to do it was, the normal way is to use a real ISP programmer with a 6-pin header cable that fits onto your board's ICSP header. Quick and straightforward as it gets in that case.

The "Arduino with the ISP sketch" is a lot of futzing around by comparison. But yes, ultimately, you should be able to get it to do the same thing.

Be aware that whenever you program via a ISP programmer, if you have a bootoader program loaded, it will be overwritten, just like any other program (because to the ISP programmer, it is just any other program.) This only matters if you intend to do both types of programming on the same chip, but if you do, you need to burn the bootloader program on there again before you can program a sketch by RX and TX using the bootloader method.

Generally, though, you will be using one method or the other for a particular project.

WiFi shields/Yun too expensive? Embeddedcoolness.com is now selling the RFXduino nRF24L01+ <-> TCP/IP Linux gateway: Simpler, more affordable, and even more powerful wireless Internet connectivity for *all* your Arduino projects! (nRF24L01+ shield and dev board kits available too.)

LastSamurai

#8
May 05, 2014, 08:17 pm Last Edit: May 05, 2014, 09:16 pm by LastSamurai Reason: 1
Thanks for that answer pico. It helped me a lot.
I do just use ISP programming then (thats fine). The problem is it does not work. I connected power to my board and connected pin 10-13 and GND from my arduino to the board. I also set the in the arduino IDE to the right (target) board, port and programmer. Uploading still does not work. I am only getting "avrdude: stk500_getsync(): not in sync: resp=0x00" errors.

PS Ok there was another error. I fixed that one and now uploading works again via breadboard and uno. I will try it directly later.

pico

#9
May 06, 2014, 04:11 am Last Edit: May 06, 2014, 08:35 am by pico Reason: 1

Thanks for that answer pico. It helped me a lot.
I do just use ISP programming then (thats fine). The problem is it does not work. I connected power to my board and connected pin 10-13 and GND from my arduino to the board. I also set the in the arduino IDE to the right (target) board, port and programmer. Uploading still does not work. I am only getting "avrdude: stk500_getsync(): not in sync: resp=0x00" errors.


There's a very good reason it doesn't work -- when you are programming using an ISP programmer from the IDE (USBasp, USBtinyISP, "Arduino-as-ISP", whatever) you must 1) specify your programmer type from "Tools|Programmer" 2)  upload your sketch from "Files|Upload Using Programmer"

The "avrdude: stk500_getsync(): not in sync: resp=0x00" message indicates you were trying to upload your sketch using the com port (i.e., via the bootloader). That's just not going to work if you are using a ISP programmer. *Don't* push the upload button. Select "Upload Using Programmer" from the "Files" menu instead.

And my heartfelt advice is if you are going to do ISP programming on a regular basis (like, more than once), make your life easier just get a real programmer rather then using the "Arduino as ISP". It's like spending the afternoon in the workshop converting your Mercedes to run as  a golf buggy. Just because you *can* do it doesn't make it the most sensible way of going about playing a round of golf.

WiFi shields/Yun too expensive? Embeddedcoolness.com is now selling the RFXduino nRF24L01+ <-> TCP/IP Linux gateway: Simpler, more affordable, and even more powerful wireless Internet connectivity for *all* your Arduino projects! (nRF24L01+ shield and dev board kits available too.)

LastSamurai

I realise it has been some time but: Thank you so much!
This is one of the few forum I know, where people really try to help each other ;)

It works excactly as you said: use the upload using programmer button. I hope if someone ever finds this he/she can use this too.

And yeah, I will get a programmer ;) Any special one that you guys suggest? Should not be too costly though ;)

pico


I realise it has been some time but: Thank you so much!


Thanks for saying thanks. You'd be surprised how few people bother with that simple nicety.


Any special one that you guys suggest? Should not be too costly though ;)


I like (and use) the USBasp. Get one with the 6 pin ISP connector preferably. I've steered people away from the USBtinyISP lately just because of the reports that they can have problems uploading sketches > 64KB (for Megas, 1284p boards etc.)

Lots of other good ones too, but the USBasp are pretty cheap, and great bang for buck, I think.
WiFi shields/Yun too expensive? Embeddedcoolness.com is now selling the RFXduino nRF24L01+ <-> TCP/IP Linux gateway: Simpler, more affordable, and even more powerful wireless Internet connectivity for *all* your Arduino projects! (nRF24L01+ shield and dev board kits available too.)

Go Up