I've got to the point in a project where I am questioning all my assumptions and basically losing hair apace. My circuit is based around an ATmega128, running at 16MHz off an ext xtal. The prototype board worked 100% fine after I tied VREF to +5V; apparently the JTAG interface isn't happy unless VREF is present. My "final" board - with no substantial change from the old circuit - is behaving really weirdly and I can't understand it.
My main question is: do you normally see this micro stop when you attempt to probe the xtal lines with a scope? Do I have too much load capacitance on these lines? (I've got about 15pF on both sides of the xtal. When I put a probe on either line, the micro stops; I don't see any oscillation on the scope, either).
Here's what I'm seeing, FWIW:
- Difficulty programming. Fuses are supposed to be 0x997f 0xff but most of the time the 0x99 gets spontaneously reset to 0x20. Even when the fuses and program write verify OK, the board doesn't always power up correctly. Bear in mind that all the micro-related stuff is electrically unchanged from the old design, which does work. The only thing that really changed is layout.
- Code that works 100% fine on the old board misbehaves on the new board - specifically I've got some I2C stuff that works OK if I inline it, but doesn't do anything if I put it inside a subroutine (!). I can't believe this is timing-related, because I've got long (multi-ms) delays inside this code, a call/ret is negligible by comparison.
- I know the clock is running at the right speed, because I put a strobe in a timer ISR and it is dead on the money.
- A board I programmed successfully here in NY was DOA when it arrived back at the customer. When he tried to read back the fuses, they were totally bogus values.