USBASP In-circuit programming

Arduino projects on the go
Post Reply
MaxZ
Posts: 330
Joined: 31 Jan 2019, 11:48
Location: Boskoop, Netherlands

USBASP In-circuit programming

Post by MaxZ »

I have started this thread to share my experiences in USBASP programming. I have built the single channel transmitter as described by Mike-K in his excellent documentation, see this threadviewtopic.php?f=24&t=609

In there he advises to program an Arduino ProMini board using USBASP ICP programming. Up to recently my only experience was serial programming using a USB to TTL converter. I succeeded eventually after drawing from the advise found in this forum, but it took a while since the information is scattered. Therefore I thought it appropriate to start this topic describing my stumbling blocks, and allowing me to pose further questions on the subject.

Firstly, you need to acquire an USBASP programmer. I purchased this one: https://nl.aliexpress.com/item/1pcs-Sma ... Title=true which came complete with a 10 to 6 pin adapter. I managed to find a second adapter, which I converted to a twin servo lead arrangement as Mike_K describes in his documentation. Pictures:
DSC03870.JPG
DSC03871.JPG
next go through these steps:

- select the correct Arduino board and programmer (same as serial programming).
- no need to select a Port, none will be shown.
- select the "USBasp" programmer.
- Do not use the arrow style upload icon on the sketch window, uploading will fail, upload the sketch using the "upload with programmer" option from the "sketch" menu in the menu bar.

You may get a warning message like avrdude: warning: cannot set sck period. Please check for usbasp firmware update. If so, ignore this message.

Hope this is useful for other newbees to ICP like me.

Cheers
Max.

Edit: I should mention that Mike has covered all of the above nicely in his documentation, it was just me being hasty and chaotic to miss that initially. Maybe the port selection (or rather lack of) could be added to take any confusion on that subject away.
Last edited by MaxZ on 13 May 2019, 08:39, edited 2 times in total.
MaxZ
Posts: 330
Joined: 31 Jan 2019, 11:48
Location: Boskoop, Netherlands

Re: USBASP In-circuit programming

Post by MaxZ »

And my first question is....... (monotonous rhythmic music in the background :D ) :

Would something disastrous happen when I inadvertently hit the S/C button or the Incr/Decr switch and shorten two pins during re-programming? In other words, should I strip everything from the board before connecting and using the programmer?

Cheers,
Max.
User avatar
Phil_G
Posts: 597
Joined: 15 Feb 2018, 23:32
Contact:

Re: USBASP In-circuit programming

Post by Phil_G »

The only pins of concern are D11, D12 and D13 Max. If the external circuitry allows these to be driven high & low, ie they're not hard-tied to 0v or +5 or held at either level by the output of some other component, then it should be fine to program in-circuit without having to disconnect anything. However you also need to consider onward connections - to say an RF module, a sensor or whatever - is that onward connection happy to be external driven? A sensor could be holding (say) D11 at 0v so attempting to drive it high with your USBASP would be a Bad Thing. The real answer is "it depends" :D
IIRC theres a whole section in the datasheet about ICSP and ways of protecting your associated circuitry (usually involving resistors to remove the low Z factor)

One thing I would add to your post is to ensure that the USBASP is the correct voltage for the target
Arduino, as both are available in 3v3 and 5v alternatives. Some USBASPs are switchable, but when
switched to 3v3 correctly power the target at 3v3 but still output 5v signals, which can be destructive.
For a 'true' 3v3 USBASP check the 'Baite' switchable ones. I checked mine and when set to 3v3 it powers the AtMega8 at 3v3, so all the ICSP signals (MISO. MOSI etc) are at 3v3.
If you cant find a true 3v3 USBASP like the 'Baite' its easiest to stick to a 5v USBASP and a 5v Arduino, then you dont have to worry.

This is my Pro-Mini ICSP adapter:

pro-mini_icsp_adapter.jpg


...and if you use Nano's, but like me you dont fit the intrusive ICSP header, heres a Nano ICSP adapter:


nano_icsp_adapter.jpg


Cheers
Phil
MaxZ
Posts: 330
Joined: 31 Jan 2019, 11:48
Location: Boskoop, Netherlands

Re: USBASP In-circuit programming

Post by MaxZ »

Phil_G wrote: 03 May 2019, 13:57 The only pins of concern are D11, D12 and D13 Max. If the circuitry allows these to be driven high & low, ie they're not hard-tied to 0v or +5, then it should be fine to program in-circuit without having to disconnect anything.
That seems to be ok then, I need to free up D11,D12 and D13 anyway to connect the programmer with one of the two servo leads to those pins.
The HF module is connected with the ppm output on D10, but both the Vraw and GND will be disconnected from the module, so I cannot imagine any problems there.
Thanks Phil.

Cheers,
Max.
Post Reply