<SOLVED> Can't ISP ATMega16U2

Go To Last Post
15 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all

 

Trying out the ATMega16U2 for the first time. Having issues with getting the Atmel ICE to read the chip though. Very strange I haven't had this for a very long time with other chips. Normally if this happens its because some chips have ISP on pins other than the usual SPI port, but that's not this case. I'm 99% sure I have the wiring right (always that 1% though). Attached is my circuit, and a screenshot of the Mega16U2 datasheet for serial programming.

 

I have tried several PCBs all the same, tried adding 100nF across the reset line, tried manually injecting an 8MHz clock on the XTAL1 line in case the internal RC isn't working (they are factory chips so should be RC by default), also tried a special jumper cable with MOSI/MISO swapped in case I stuffed that up. I also tried removing U2 which also sits on the SPI lines, and R2 as well in case the pullups were the issue.

 

Any other thoughts? I'm sure it's something stupid I've missed.

 

Cheers - Matt

 

Attachment(s): 

This topic has a solution.
Last Edited: Fri. Nov 27, 2020 - 12:37 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You're applying power to both Vcc and AVcc, correct? The ICE doesn't supply power. You've got a ceramic cap on both power pins?

 

edit:

ICE cable is in the AVR port not the ARM port right? I've been there before.

Last Edited: Wed. Nov 25, 2020 - 04:13 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes I have 3V3 coming in on P2. I don't have anything on the USB pins, not sure if that makes a difference.

 

There is only 1 x 100nF cap, but both power pins are almost next to each other, and I have a 2u2 next to that too. This exact same circuit worked ok for a Tiny44 on my previous version, but I have supply issues so I've changed to the Mega16U2 which has some more stock levels.

 

Yes cable is in the AVR port. I have also checked with a different product and I can read from that ok, so the ICE and interface cable is ok.

 

Matt

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

1K on the reset line maybe too low but should work, have you tried removing it or increasing it to say 10K?

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

1K on the reset line maybe too low but should work, have you tried removing it or increasing it to say 10K?

I had checked on the CRO and it's dropping to 0V no problems. Just tried removing it and no difference.

 

Also the MOSI and CLK line are both toggling ok, the MISO line doesn't do anything (held high), but I assume it's not doing anything since the chip isn't responding.

 

Cheers - Matt 

Last Edited: Wed. Nov 25, 2020 - 04:41 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mbotherway wrote:
(they are factory chips so should be RC by default)

I'm not sure that is true for the Usb chips, don't they expect to find a xtal/caps and are factory loaded with a DFU bootloader?   I could be wrong....

 

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:

mbotherway wrote:

(they are factory chips so should be RC by default)

 

I'm not sure that is true for the Usb chips, don't they expect to find a xtal/caps and are factory loaded with a DFU bootloader?   I could be wrong....

 

Jim

 

 

Hmmm the datasheet contradicts itself...

 

Page 248 describing the fuse bytes. "The default setting of CKSEL3..0 results in External crystal Oscillator 8MHz. See Table 8-1 on page 29 for details."

 

So then under Table 8-1 we have:

 

8.3.1 Default Clock Source
The device is shipped with internal RC oscillator at 8.0 MHz and with the fuse CKDIV8 programmed, resulting in 1.0 MHz system clock. The startup time is set to maximum and time-out period enabled. (CKSEL = "0010", SUT = "10", CKDIV8 = "0"). The default setting ensures that all users can make their desired clock source setting using any available programming interface.

 

I suspect you're right and I need to add external clock. I had tried adding an 8MHz sine wave, maybe I didn't have the right voltage, or didn't get my jumper wire soldered good enough. I will try that again tomorrow.

 

Cheers - Matt

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

8MHZ sinewave??
Surely you mean square wave

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kuch wrote:
8MHZ sinewave?? Surely you mean square wave

 

Maybe??? I'm sure when I've probed a crystal oscillator previously it's been a sine wave. I can try square wave too.

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Solved it. It does need an external clock. I had one of those lying in bed moments last night and I realised I my signal generator defaults to AC coupled. This morning I tried again with a DC offset to half rail, verified it on a CRO and the Mega16U2 came alive. Strangely though it won't let me swap fuses to the internal RC. Anyway I'm going to change chips regardless as I don't have room for a crystal, and it's really not needed for this application.

 

Thanks for the guidance everyone! - Matt

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mbotherway wrote:
Solved it.

Jolly good. See Tip #5 in my signature, below, for how to mark the solution:

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

If you don't have room for a crystal why on earth did you select a USB AVR? The main selling point of 16U2 is that it's a small chip that includes USB.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

If you don't have room for a crystal why on earth did you select a USB AVR? The main selling point of 16U2 is that it's a small chip that includes USB.

 

Age old problem of size vs availability.

 

My first version of this PCB actually had a Tiny44A on it (Designed several months ago). As we were about to go to production 2 weeks ago, my order requirement went from about 500 to 15,000. And I couldn't find 15,000 Tiny44s anywhere (even buying from multiple vendors). So I had to change and it was a case finding a chip which had stock and would fit on my tiny PCB. The Mega16U2 fit the bill. Even though it's over featured for what I need, they were available and fit. Even since the new prototype with the Mega16U2 stock levels of those have dropped too. So will be back to the drawing board for this one.

 

Cheers - Matt

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Great problem to have!

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mbotherway wrote:
And I couldn't find 15,000 Tiny44s anywhere (even buying from multiple vendors).
though BGA 0.65mm pitch so the PCB design may be a bit of a challenge :

https://www.microchipdirect.com/product/ATTINY44A-CCUR

 

 

"Dare to be naïve." - Buckminster Fuller