Author Topic: Could a USBasp help me fix my messed up 16U2?  (Read 7113 times)

0 Members and 1 Guest are viewing this topic.

Offline dentakuTopic starter

  • Frequent Contributor
  • **
  • Posts: 881
  • Country: ca
Could a USBasp help me fix my messed up 16U2?
« on: August 21, 2015, 04:15:36 pm »
I have a Arduino UNO R3 clone from Sintron with a 328P-PU and a ATmega16U2.
The 328 is working fine because the last sketch I programmed on it still works. The 16U2 seems to me messed up because I can't make it enter DFU mode to even start attempting to fix it and it just keeps identifying itself as Arduino Uno (Com3) no matter what I do.
I can't upload anything to the UNO anymore, I don't own a programmer of any sort and I don't have another Arduino I could use with the Arduino as ISP sketch.

QUESTIONS:
- If I get a USBasp with a 6pin connector (I can probably make my own adapter) and connect it to the 6 pin header next to the USB port will it help me try to fix the 16U2 with either AVRDude or Flip?
- If the 16U2 IS unfixable, I see that the USBasp shows up in the list of official programmers the Arduino IDE supports (I prefer Atmel Studio6 though) so at least I can use the USBasp to program this otherwise useless UNO by connecting it to the 6pin header on the right edge of the UNO?
- Is there a better inexpensive tool than the USBasp I would need

I've done the loopback test and nothing echoes back.
I'm sure the Arduino shows up in Device Manager on COM3 and goes away if I unplug it.
The IDE is set to Board:UNO and Port: COM3.
I updated from 1.6.0 to 1.6.5
Tried it on both my Win7 computer and an old WinXP laptop.
Tried it with Atmel Studio / Visual Micro.
There's nothing connected to pins 0 or 1 (or any pins at the moment).
A new USB cable didn't help
 

Offline Tainer

  • Contributor
  • Posts: 37
  • Country: 00
Re: Could a USBasp help me fix my messed up 16U2?
« Reply #1 on: August 23, 2015, 09:05:43 am »
Never used an arduino, but I'll try to help.
I have a Arduino UNO R3 clone from Sintron with a 328P-PU and a ATmega16U2.
Do you mean it's a board with atmega328 as the main microcontroller and atmega16 used as UART-USB converter? I would suggest sending some random bytes via terminal and probing TX line with a logic analyzer or a scope. If you have none of these tools then set your meter to volts and send a very long string of characters over COM3 - you will notice some change if it's transmitting. If it's working fine, then it might be a bad connection between the two microcontrollers - try reseating your 328 (it's usually socketed on arduino boards) and check solder joints.

- Is there a better inexpensive tool than the USBasp I would need
You could buy a cheap uart-usb converter board (FTDI, CP210x, etc) and use it as a bit-bang programmer. If you have an old PC with LPT port then you already have a programmer ;) (google 'AVR LPT programmer').
 

Offline ralphd

  • Frequent Contributor
  • **
  • Posts: 445
  • Country: ca
    • Nerd Ralph
Re: Could a USBasp help me fix my messed up 16U2?
« Reply #2 on: August 23, 2015, 01:42:26 pm »
Your plan sounds reasonable.
A usbasp is <$2 on Aliexpress, or for about $2.5 you could get a pro mini and USB-ttl adapter, and run the ArduinoISP sketch on the pro mini.
If you are going to do work on AVRs, I'd suggest getting both.  I have a couple different USBasps and several USB-ttl adapters.
Unthinking respect for authority is the greatest enemy of truth. Einstein
 

Offline dentakuTopic starter

  • Frequent Contributor
  • **
  • Posts: 881
  • Country: ca
Re: Could a USBasp help me fix my messed up 16U2?
« Reply #3 on: August 24, 2015, 10:31:05 am »
Your plan sounds reasonable.
A usbasp is <$2 on Aliexpress, or for about $2.5 you could get a pro mini and USB-ttl adapter, and run the ArduinoISP sketch on the pro mini.
If you are going to do work on AVRs, I'd suggest getting both.  I have a couple different USBasps and several USB-ttl adapters.

I'm going to get a http://www.dipmicro.com/store/USBASP2 and a $2 http://www.dipmicro.com/store/PL2303HX-MOD ordered from Canada so I don't need to wait for them to come from China.
 

Offline dentakuTopic starter

  • Frequent Contributor
  • **
  • Posts: 881
  • Country: ca
Re: Could a USBasp help me fix my messed up 16U2?
« Reply #4 on: August 29, 2015, 02:46:17 am »
I got a USB-TTL adapter and it shows up fine as COM5. I opened up Teraterm and the TX light blinks when I type characters.

Question:
Before messing with  trying to fix the 16U2 (I also got a USBASP) I'd like to see if I can still program this UNO just using the TX/RX pins as you would with a Pro Mini or something that doesn't have it's own USB-TTL chip onboard.
This adapter has 5 pins (3V3, TXD, RXD, GND, +5V and unfortunately no reset functionality). When programming an Arduino UNO with one of these what do I do with the +5V and GND?
The RX goes to TX and the TX goes to RX, that's logical, but when programming an UNO that's already got it's own power source do I need the +5V and GND?
What about having to hold down the Reset button when programming this way?
 

Offline retrolefty

  • Super Contributor
  • ***
  • Posts: 1648
  • Country: us
  • measurement changes behavior
Re: Could a USBasp help me fix my messed up 16U2?
« Reply #5 on: August 29, 2015, 02:53:22 am »
I got a USB-TTL adapter and it shows up fine as COM5. I opened up Teraterm and the TX light blinks when I type characters.

Question:
Before messing with  trying to fix the 16U2 (I also got a USBASP) I'd like to see if I can still program this UNO just using the TX/RX pins as you would with a Pro Mini or something that doesn't have it's own USB-TTL chip onboard.
This adapter has 5 pins (3V3, TXD, RXD, GND, +5V and unfortunately no reset functionality). When programming an Arduino UNO with one of these what do I do with the +5V and GND?

Ground must be wired to arduino ground pin. +5vdc from adapter can either be left unconnected (if Uno already has power applied, or connected to arduino's +5vdc pin if you wish the adapter to power the Uno.

The RX goes to TX and the TX goes to RX, that's logical, but when programming an UNO that's already got it's own power source do I need the +5V and GND?

It's not always TX to RX and RX to TX, as there is no standard as to if a given modules TX is an output or input (meaning to wire to the remotes TX). Best to test, as one only wants input pins connecting to output pins and visa versa, outputs to outputs will release magic smoke. Again ground must be connected to Uno, +5vdc is optional depending on how you wish to power the arduino up.

What about having to hold down the Reset button when programming this way?

Without auto-reset feature one must hold down reset and only release when the arduino IDE completes compilation and starts the upload process. It can take some practice to get the timing correct, but it does work.
« Last Edit: August 29, 2015, 02:56:09 am by retrolefty »
 

Offline dentakuTopic starter

  • Frequent Contributor
  • **
  • Posts: 881
  • Country: ca
Re: Could a USBasp help me fix my messed up 16U2?
« Reply #6 on: August 29, 2015, 01:11:12 pm »
I got a USB-TTL adapter and it shows up fine as COM5. I opened up Teraterm and the TX light blinks when I type characters.

Question:
Before messing with  trying to fix the 16U2 (I also got a USBASP) I'd like to see if I can still program this UNO just using the TX/RX pins as you would with a Pro Mini or something that doesn't have it's own USB-TTL chip onboard.
This adapter has 5 pins (3V3, TXD, RXD, GND, +5V and unfortunately no reset functionality). When programming an Arduino UNO with one of these what do I do with the +5V and GND?

Ground must be wired to arduino ground pin. +5vdc from adapter can either be left unconnected (if Uno already has power applied, or connected to arduino's +5vdc pin if you wish the adapter to power the Uno.

The RX goes to TX and the TX goes to RX, that's logical, but when programming an UNO that's already got it's own power source do I need the +5V and GND?

It's not always TX to RX and RX to TX, as there is no standard as to if a given modules TX is an output or input (meaning to wire to the remotes TX). Best to test, as one only wants input pins connecting to output pins and visa versa, outputs to outputs will release magic smoke. Again ground must be connected to Uno, +5vdc is optional depending on how you wish to power the arduino up.

What about having to hold down the Reset button when programming this way?

Without auto-reset feature one must hold down reset and only release when the arduino IDE completes compilation and starts the upload process. It can take some practice to get the timing correct, but it does work.

I used my scope and see that TX on the USB-TTL adapter is an output that is normally High and goes Low if I type characters into Teraterm so that works as an output as expected.

Which +5V on the UNO do you mean? I've always thought of the 5V pin (next to GND, GND) as just an output connected to the regulator but can they be used to also power the UNO if it doesn't have any other source of power connected to it?
The official site says this
-5V.This pin outputs a regulated 5V from the regulator on the board. The board can be supplied with power either from the DC power jack (7 - 12V), the USB connector (5V), or the VIN pin of the board (7-12V). Supplying voltage via the 5V or 3.3V pins bypasses the regulator, and can damage your board. We don't advise it.
It's not that I have any problems using a +9V DC plug to power it it's just that it would be easier to use the +5V from the USB-TTL adapter.

I've also never used the Vin (9V) and IOREF pins before but I guess that's a subject for another post.
« Last Edit: August 29, 2015, 01:17:27 pm by dentaku »
 

Offline ralphd

  • Frequent Contributor
  • **
  • Posts: 445
  • Country: ca
    • Nerd Ralph
Re: Could a USBasp help me fix my messed up 16U2?
« Reply #7 on: August 29, 2015, 01:56:30 pm »
I got a USB-TTL adapter and it shows up fine as COM5. I opened up Teraterm and the TX light blinks when I type characters.

Question:
Before messing with  trying to fix the 16U2 (I also got a USBASP) I'd like to see if I can still program this UNO just using the TX/RX pins as you would with a Pro Mini or something that doesn't have it's own USB-TTL chip onboard.
This adapter has 5 pins (3V3, TXD, RXD, GND, +5V and unfortunately no reset functionality). When programming an Arduino UNO with one of these what do I do with the +5V and GND?
The RX goes to TX and the TX goes to RX, that's logical, but when programming an UNO that's already got it's own power source do I need the +5V and GND?
What about having to hold down the Reset button when programming this way?
You could try my zero-wire auto-reset technique.
http://nerdralph.blogspot.ca/2014/02/zero-wire-serial-auto-reset-for-arduino.html
Or use your usbasp to flash picobootSTK500, which uses reset to toggle the bootloader mode where it just waits for the code to flash.
http://nerdralph.blogspot.ca/2015/06/picobootstk500-v1-release.html

Unthinking respect for authority is the greatest enemy of truth. Einstein
 

Offline dentakuTopic starter

  • Frequent Contributor
  • **
  • Posts: 881
  • Country: ca
Re: Could a USBasp help me fix my messed up 16U2?
« Reply #8 on: August 29, 2015, 05:01:15 pm »
Well... As I knew from the start, this UNO works fine because it was running the sketch that was last put on it before the 16U2 messed up and just now I plugged a 9V adapter into the barrel jack, connected the GND, TX and RX of the USB-TTL adapter to the correct headers, held down the RESET button as the sketch compiled and let go when it said Uploading and I managed to program the Blink sketch into it.
I also tried it with AVRStudio and it works well too.

I guess now the next step is to find out if my new USBASP works, learn how to use it and to try to put a new .hex file in the 16U2.
The place I got it from says this https://www.dipmicro.com/store/USBASP2

This programmer is intended to be used with Windows GUI based ProgISP 1.72.

If you prefer to reprogram it to use with AVRDUDE, please read this article. You will need second AVR programmer for this. If you prefer this version, we can reprogram your programmer at no charge, just leave a note with your order that you want us to reflash it.

NOTE: when using with AVRDUDE, you may need to specify -B 10 option to set the clock otherwise AVRDUDE may fail.

Command line to reprogram this programmer to USBASP:
avrdude.exe -p m8 -c usbasp -P usb -U flash:w:"20130212_mega8_usbisp.hex":a -U lfuse:w:0xef:m -U hfuse:w:0xc9 -F


I don't mind using ProgISP 1.7.2 if it lets me re-flash the 16U2. As long as it works, that's OK.
I left a note with my order to have them reflash it but I haven't checked to see if it was done. I guess first I need to find out how to check if it was done or not :)
 

Offline dentakuTopic starter

  • Frequent Contributor
  • **
  • Posts: 881
  • Country: ca
Re: Could a USBasp help me fix my messed up 16U2?
« Reply #9 on: August 29, 2015, 06:22:07 pm »
Well, the USBasp I got seems like it was reflashed by the people I bought it from because it shows up in Device Manager as USBasp, it failed to install drivers like it' supposed to so I pointed it to the folder I downloaded the libusb_1.2.4.0 drivers to and it looks like it's OK.

I believe the .HEX file I'm looking for to try and fix the 16U2 is C:\Program Files (x86)\Arduino\hardware\arduino\avr\firmwares\atmegaxxu2\arduino-usbserial\Arduino-usbserial-atmega16u2-Uno-Rev3.hex
Or do I want C:\Program Files (x86)\Arduino\hardware\arduino\avr\firmwares\atmegaxxu2\Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3

If the 16U2 is unrecoverable at least I can just keep using it with the USB-TTL adapter because it works fine that way.
« Last Edit: August 29, 2015, 11:47:32 pm by dentaku »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf