Monday, April 16, 2012

AVR JTAG programming oddities

I recently launched a new project, I'm working on a bench power supply. I've wanted to do the "old ATX PC PSU to bench power supply" thing for a while, and there was a recent series on the EEVBLOG whose design I'm taking a lot of inspiration from. (That David Jones is a freakin' genius). I want to have a little more "kapow" than his design, 0-9 V, 3 channels. I don't know if that's a folly on my part, but time will tell.

I finished up the "thinking a lot about it" phase, where I watch TV and daydream about what I want to do, and I moved into the prototype/experiment/pre-design phase.

I'm going to use an ATmega 644 as the main MCU to drive my logic. I'm wavering between that and the ATmega 328, but I just think the 328 probably doesn't have enough pins.

I've thrown together a few lines of code for doing the LCD display logic, using a "HD4478x" library for AVR's I found on the internet(I'll wait until my project is farther along before giving credit, since I might swap it out or roll my own in the end).

I went to test on a breadboard tonight and I discovered something very perplexing that I've not run into before...



With only the ATmega 644, a few conditioning caps, a 20mhz crystal, and my AVR dragon with a home made JTAG-breadboard adapter, I get very unreliable programming/debugging when I'm powering the board with 5 Volts. If I power it with 3.3, I can program and debug virtually flawlessly. The problem is that my LCD needs to be driven by a 5 volt supply, and I was intending on building a 5 volt circuit anyways.

It's really strange. I had been running the board at 3.3, but moved to 5V when I wired in my LCD connections. That's when I noticed a lot of strange debugging behavior. At first, I thought the AASaver I was using to power the board might be introducing to much supply noise. (I've ordered and assembled a few of these cool little gadgets I mentioned last month, I'm planning to do a post/review about them. In the mean time, I did run it through a scope, and there is some ripple on the output). Since the AASaver is a switched supply, I used a Sparkfun linear Breadboard regulator. It was no better.

I removed and rewired my LCD connections several times, thinking maybe the LCD controller was introducing noise, or the additional load was exaggerating supply noise. It didn't seem to make a difference.

I knew it was working fine when I had first assembled the 644, so on a lark I dropped back down to 3.3V. The programming and JTAG immediately started working again.

It's times like this I really feel dumb, not because I did something stupid, but because I don't know what stupid thing it is that I've done. I'm not even sure where to look. If anything, I'd have thought running at 5Volts would be more reliable.

If anyone who reads this has any obvious things to check, please leave a comment. I'm out of time for now. When I have more time, I'll check my next suspect, the crystal. I know every schematic I ever see has 6-20 pF caps on the crystals, and I never put the caps on the crystals, and it always seemed to work fine in the past. This schematic is so simple, other than some conditioning and/or pull-up  resistors on the JTAG lines, I'm not sure what else it could possibly be.


-P




1 comment:

  1. It could also be that my beloved Dragon is in early stages of dementia, I recently ordered a DSO Quad scope which might give me a way to analyze what's going on.

    ReplyDelete

I welcome you're thoughts. Keep it classy, think of the children.