I’ve been getting more into the world of electronics these days. My son loves the simple little toys that I make for him. He’s encouraged me to learn more and build bigger and better things. It’s starting to turn into an expensive hobby for me. This is what my “lab” looks like now:
One of the things I’ve been trying recently is to buy the electronic components directly from China through eBay and AliExpress. I figured I’d cut out the middle man and go straight to the source. What could go wrong?
Well other than having to wait about a month for a delivery its been working out great so far. Until last week, when I received a batch of “dead” ATmega48 MCUs. I ordered a bunch of Atmel MCUs to test. I wanted to see if I would really get “genuine” and/or working Atmel chips. Here is what I ordered:
- 10 x ATmega328P for $13.69
- 10 x ATmega48 for $7.10
- 10 x ATtiny2313 for $8.48
- 10 x ATtiny85 for $11.90
- 10 x ATtiny13A for $5.18
I tested them all with simple LED blink programs I wrote in Atmel Studio 7 using AVRDUDE and a USBasp programmer. I was pleasantly surprised to find that every single chip worked except for the batch of ATmega48’s. This is the error AVRDUDE displayed when I tried to program them:
avrdude: error: program enable: target doesn't answer.
1 avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
I tried different programmers and settings, nothing worked. I was about to toss them but I started to wonder if the fuse bits had been changed. I brought out my AVR Dragon and started to wire up the high voltage pins to try to read the fuse bit settings. Here is what the setup looks like:
You have to connect a lot of pins… Here’s a tip for anyone trying to figure out how to connect the AVR Dragon for HVSP. Look through the various device sheets here and find the one that lists your MCU in the “applicable to the following devices” section. The ATmega48 is listed in Devicesheet: SCKT3200D2. I don’t know why Atmel did that, it took me forever to figure it out the first time.
After getting everything wired up I opened the device programmer in Atmel Studio, selected AVR Dragon, and tried to read the fuse bit settings. I found that all 10 had the internal oscillator disabled and other random changes. This is why AVRDUDE was failing. I used a fuse calculator, here, to get the default fuse settings for the ATmega48 and reset the fuses on all the chips. I had no problems with them after this.
I guess they must have sent me someone’s pre-programmed ATmega48’s. I forgot to check the flash memory to see if it had anything. This is the risk you take when ordering from eBay. I don’t know if they are genuine but they all appear to be working.
So I ended up with 50 MCUs for less than a dollar each. The same lot of MCUs from Mouser would cost around $80 with shipping. I think it is worth the gamble if you don’t mind waiting a month for shipping and if you have a high voltage serial programmer such as the AVR Dragon or Fusebit Doctor to fix any potential issues.