OK guys i have been using atmega328p-au to make a capacitive touch panel. But I am having hard time programming it. First i tried to bootload it using my arduino mega, but it didn’t work. So then i used my raspberry pi and avrdude to upload the bootloader hex file. It got uploaded but when i tried the blink sketch it didn’t work. I figured out i needed to change the fuse bits. So first i changed the lfuse to 0xFF which is arduino uno default and as soon as i did it avrdude kept showing error atmega not responding.After lots of googleing i found that now the atmega is trying to use external crystal, but i have connected the crystal, triple checked every connection but still nothing. Please help me guys. I have uploaded my schematics and real pcb pics.
Where is the 0.1uf decoupling capacitor between Vcc and Gnd, and the other one between AVcc and Gnd? These are necessary, despite people persistently posting "guides" that omit them (the number of guides missing this basic component raises some questions, for sure). I have had problems programming AVR devices without them (and stability problems even if I do get it programmed). Generally speaking, you should assume a 0.1uf cap between supply and ground (recommended one per pair of vcc/gnd pins) is required on every digital IC unless specified otherwise in the datasheet.
AREF should not be tied to Vcc. (doing that can damage the chip if you set the analog reference to anything other than the default).
Are the loading capacitors appropriate for the crystal you're using? You need to be sure you're using loading caps of the right value for the crystal (approximately).
What errors do you get when trying to program it via ISP?
I am powering the board from 5v of raspberry pi, do i really need those capacitors. And i am not using any analog function. The caps arohnd the crystal are 22pf as specified by arduino
Yes, you do need those capacitors. You need them on every digital IC, as I said above, and as close to the part as possible. I've had to trash boards I had made because the the cap was a couple of inches away, and I couldn't program the chip without dead-bugging on an extra cap right across the pins...
You should be sure to correct the handling of AREF in the next version - it's never good for a built-in function like analogReference() to actually be burnOutAnalogReference()
But is the crystal a 22pf crystal? The caps are largely dependent on the crystal.
What errors do you get?
well i did flash the blink.hex without those caps and it was sucessful. But i will listen to you on that and add caps. And the avrdude shows error "AVR not responding". and my research showed me that its happening because as i programed the lfuse its now looking for crystal and until i connect a crystal it wont work.
Thing about missing decoupling caps is, it's very unpredictable - it may work in some situations, and not others. Debugging nightmare, and that's why I'm such a hardass about it on here.
Enable verbose upload and copy/paste the error, including the first line where it shows the command it's invoking (this shouldn't contain any surprises, but it's shocking how often people post it and we realize we'd been miscommunicating a crucial detail)
Normally the crystal issue will result in a signature error (and verbose upload will report that it's seeing 0x000000 for the signature), not the device does not answer error...
So before you soldered that huge crystal, have you tested it with a breadboard atmega328P-PU system? I've got crystals like that that didn't work (maybe requiring some different load capacitors than 22pF).
If you changed lfuse and your board stops working, it's got to be the crystal. You either have short circuited its pins (to each other or to gnd, underneath the metal cap or at the MCU pins, I've done it) or have crystals that don't work (or mismatched load capacitor). I once bought a bag of 100 crystals that don't work. Some do but most don't. You figure! Since then I only get my crystals from reputable vendors. You can replace 22pF with maybe 17pF but if you have a bad crystal, nothing will work.