I am building a few devices based on some AVR µCs (4 ATtiny84s and a single ATmega328P). I will have a few modules attached which need to run at 3.3v (nRF24L01 transceivers and a ST7735 LCD) and I'd really like to do in-circuit serial programming so I don't need to remove the µC from its socket or have to disconnect the modules every time I compile and upload the code. The PCB which I have designed but not yet sent for manufacturing has a provision for a standard 6-pin ICSP header and it would be great if I could make use of it.
I have three USBasp programmers and all of them always upload the sketch flawlessly at 5v but as soon as I switch the jumper to 3.3v it fails randomly, sometimes many times in a row and other times rarely. I also have the impression that one of the USBasp programmers fails more often than the others but it may be a coincidence. When the upload fails, the LED which is supposed to blink does not turn on at all. Once it's successful again (which can be forced by using 5v or happens on its own after multipe retries), the LED blinks as expected.
I've tried a decoupling capacitor between Vcc and GND and a pull-up resistor on the reset pin to no avail. I made sure the firmware on all three is up to date and I've tried using a different ATtiny chip and an ATmega and the problem persists.
Below is the very basic code I'm testing with and the output from the Arduino IDE (in this case I have an ATtiny85 connected):
void setup() {
pinMode(3, OUTPUT);
}
void loop() {
digitalWrite(3, HIGH);
delay(1000);
digitalWrite(3, LOW);
delay(1000);
}
Sketch uses 458 bytes (5%) of program storage space. Maximum is 8192 bytes.
Global variables use 9 bytes (1%) of dynamic memory, leaving 503 bytes for local variables. Maximum is 512 bytes.
"C:\Users\neu\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino18/bin/avrdude" "-CC:\Users\neu\AppData\Local\Arduino15\packages\ATTinyCore\hardware\avr\1.5.2/avrdude.conf" -v -pattiny85 -cusbasp "-Uflash:w:C:\Users\neu\AppData\Local\Temp\arduino\sketches\489E94CF512C274DFBBBE22A8474D1CE/Blink.ino.hex:i"
avrdude: Version 6.3-20201216
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "C:\Users\neu\AppData\Local\Arduino15\packages\ATTinyCore\hardware\avr\1.5.2/avrdude.conf"
Using Port : usb
Using Programmer : usbasp
Setting bit clk period : 5.0
AVR Part : ATtiny85
Chip Erase delay : 400000 us
PAGEL : P00
BS2 : P00
RESET disposition : possible i/o
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 12 4 0 no 512 4 0 4000 4500 0xff 0xff
flash 65 12 32 0 yes 8192 64 128 30000 30000 0xff 0xff
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
lock 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
calibration 0 0 0 0 no 2 0 0 0 0 0x00 0x00
Programmer Type : usbasp
Description : USBasp, http://www.fischl.de/usbasp/
avrdude: set SCK frequency to 187500 Hz
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e930b (probably t85)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: set SCK frequency to 187500 Hz
avrdude: reading input file "C:\Users\neu\AppData\Local\Temp\arduino\sketches\489E94CF512C274DFBBBE22A8474D1CE/Blink.ino.hex"
avrdude: writing flash (458 bytes):
Writing | ################################################## | 100% 0.33s
avrdude: 458 bytes of flash written
avrdude: verifying flash memory against C:\Users\neu\AppData\Local\Temp\arduino\sketches\489E94CF512C274DFBBBE22A8474D1CE/Blink.ino.hex:
avrdude: load data flash data from input file C:\Users\neu\AppData\Local\Temp\arduino\sketches\489E94CF512C274DFBBBE22A8474D1CE/Blink.ino.hex:
avrdude: input file C:\Users\neu\AppData\Local\Temp\arduino\sketches\489E94CF512C274DFBBBE22A8474D1CE/Blink.ino.hex contains 458 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 0.15s
avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
0x00 != 0x0e
avrdude: verification error; content mismatch
avrdude done. Thank you.
Failed programming: uploading error: exit status 1
How can I solve this? Thanks!