Arduino Forum

Using Arduino => Avrdude, stk500, Bootloader issues => Topic started by: IanStMartin on Jan 10, 2019, 05:46 pm

Title: USBasp programmer for 28 pin DIL
Post by: IanStMartin on Jan 10, 2019, 05:46 pm
Hello

I bought a 3.3v Pro Mini, and a USBasp programmer cable.
All well there... installed it into the IDE and I can program the 3.3v Mini fine.

I also have here some ATMega328p 28 pin DIL IC's.  No idea when I got them, but they are new.

I found the attached image on Google, and have been playing, but cannot get it to upload with the USBasp  (Processor set to ATMega328p, 3.3v. 8Mhz - upload using programmer).

My questions therefore...

1/  Is this chip programmable at 3.3v? Can't see why not, but I may be wrong
2/  Does it need the external crystal (8Mhz) attached, or should it upload without it?
3/  What am I missing?  Clearly something

Many thanks
Title: Re: USBasp programmer for 28 pin DIL
Post by: pert on Jan 10, 2019, 08:47 pm
IanStMartin's picture:
(http://forum.arduino.cc/index.php?action=dlattach;topic=590016.0;attach=289504)


1/  Is this chip programmable at 3.3v? Can't see why not, but I may be wrong
Yes.

2/  Does it need the external crystal (8Mhz) attached, or should it upload without it?
It depends on whether the fuses have been configured to require an external clock source. If so, then you won't be able to do anything with the chip until you provide a clock source, even if you only connect it just long enough to set the fuses to use the internal oscillator. The factory default fuse setting is to use the internal oscillator. However, if you buy chips "with Arduino bootloader", they will be set to use an external clock since they are expected to be put in an Uno.

cannot get it to upload with the USBasp  (Processor set to ATMega328p, 3.3v. 8Mhz - upload using programmer).
Note that you need to use a Tools > Board selection in the Arduino IDE that is configured for the internal oscillator and then do a Tools > Burn Bootloader to set the fuses correctly. The Pro Mini uses an external oscillator so you can't use that board definition. I recommend using MiniCore, which does have an internal clock selection (Tools > Clock > 8 MHz internal):
https://github.com/MCUdude/MiniCore (https://github.com/MCUdude/MiniCore)

3/  What am I missing?  Clearly something
You should make a connection to the other ground pin.

You should make a connection between the two power rails on your breadboard.

You should have a 0.1 uF decoupling capacitor on both power lines into the chip, as close to the chip as possible.

Like this:
(http://www.gammon.com.au/images/Arduino/Minimal_Arduino1.jpg)

That image is from Nick Gammon's excellent tutorial:
http://www.gammon.com.au/breadboard (http://www.gammon.com.au/breadboard)
Title: Re: USBasp programmer for 28 pin DIL
Post by: IanStMartin on Jan 11, 2019, 05:35 pm
Thanks Pert.

I installed the MiniCore board tools

I did have the board wired correctly (all 0v's and +3.3v to correct pins + 0.1uf caps).  The image was just to show the Mosi/Miso/Clk connections.

Took some playing around, but finally got it to upload code using external 8Mhz crystal (just would not do internal).

My next question, seeing as Google failed to provide anything I could understand!...

Is there any way of using serial monitor with the USBasp?  I would like to Serial.print my variables for testing to the serial monitor the same way I do when using an Uno or Mega.

If not through the USBasp, then some other way?
Title: Re: USBasp programmer for 28 pin DIL
Post by: pert on Jan 11, 2019, 09:47 pm
I'm glad to hear it's working now.

Regarding your question about the USBasp: Some 10 pin USBasps (not all) have the serial lines connected to pins 4 (RX) and 6 (TX) on the ICSP cable to permit this functionality:
(https://i.stack.imgur.com/elBcb.png)
There is a custom USBasp firmware that allows the use of this functionality:
https://community.atmel.com/projects/usbasp-tty-usbasp-programmer-modified-serial-support-and-terminal-program (https://community.atmel.com/projects/usbasp-tty-usbasp-programmer-modified-serial-support-and-terminal-program)

I've never tried it, but it would be nice.
Title: Re: USBasp programmer for 28 pin DIL
Post by: IanStMartin on Jan 11, 2019, 09:58 pm
Many thanks Pert.

I am away tomorrow.  I will have a look into this when I am home.
Never thought to check the 10 pin connector on the USBasp.  I am connected to the 10 pin socket with the 6 pin adapter that came with it.

Cheers
Title: Re: USBasp programmer for 28 pin DIL
Post by: IanStMartin on Jan 12, 2019, 11:47 am
That's annoying....

 https://www.bitsbox.co.uk/data/modules/USBasp1.pdf (https://www.bitsbox.co.uk/data/modules/USBasp1.pdf)

Doesn't look like my USBasp has the RX/TX pins wired.

Not sure I am competent enough to flash the USBasp.

Is there any way I could take the RX/TX pins of my ATMega328p and fire them through a spare UNO RX/TX and obtain the data that way?
I have an Uno set up as a programmer here.
Title: Re: USBasp programmer for 28 pin DIL
Post by: pert on Jan 12, 2019, 03:24 pm
Is there any way I could take the RX/TX pins of my ATMega328p and fire them through a spare UNO RX/TX and obtain the data that way?
Yes, you can do that. Usually how people do this is to upload a BareMinimum sketch to the Uno so that the primary microcontroller won't interfere with communication. Then you need to make the connections between your ATmega328P and the Uno RX-RX, TX-TX. That seems wrong, but what you're actually doing is communicating directly between the ATmega328P and the USB to serial chip on the Uno. Since that USB to serial chip is connected to the Uno's ATmega328P RX-TX, TX-RX, when you connect to the Uno RX-RX, TX-TX you're actually making an RX-TX, TX-RX connection to the USB to serial chip.

Much less confusing is to get a dedicated USB to serial adapter. They are very cheap, readily available from the usual sources, and a handy tool to have.
Title: Re: USBasp programmer for 28 pin DIL
Post by: IanStMartin on Jan 12, 2019, 03:55 pm
Thank you for all your advice Pert.
I will have a play around tomorrow once the living room decorating is done!