I’ve been using Arduinos, but now have built a „barebone“ ATMega328P circuit (see the circuit ) which needs to run at 3.3V so that I can interface it later to some other 3.3V components. I’ve used a 12MHz crystal.
To program it I’ve tried to use the Pololu USB AVR Programmer v2 and the Arduino IDE. I’ve set the COM port to that shown by the Pololu utility and have used, as board, the Adafruit Pro Trinket 3V 12MHz which seems to be the closest match.
Alas it did not work and gave the error message “Initial SPI command failed” (see this screen shot and the IDE messages ). I’ve checked the connections and also tried some different frequencies (although 114 kHz seems well within the spec). I eventually looked at the waveforms for RST and SCK when the Arduino IDE starts programming (I’ve used the menu item “upload with programmer”) and got this
This confused me as I would expect to see some pulses on SCK. I tried doing the whole thing again without the ATMEGA , i.e. directly measuring what the programmer delivered, but at 5V and using the Arduino UNO as board in the IDE and got this and this . The lack of pulses on SCK seemed wrong.
I’m aware that I’m probably making a colossal mistake here, but if anyone can provide any hints as to where I’m going wrong I’d be grateful.
Thank you for providing so much information about the issue. Can you send pictures showing how you are connecting the AVR programmer to your circuit? Also, how are you powering your circuit?
I just studied the datasheet for the Atmega328P and came over:
“ Speed Grade:
̶ 0 - 4MHz@1.8 - 5.5V, 0 - 10MHz@2.7 - 5.5.V, 0 - 20MHz @ 4.5 - 5.5V”
For me it look like it’s not really save to use 12MHz with 3V.
Many thanks for your quick reply.
My original circuit had the barebones AVR connected to an ESP8266 over the SPI bus. I was pretty sure that this would interfere with ISP programming, so left the ESP8266 powered off, but still connected. When you asked to send a photo of the wiring, I thought I’d should remove these connections so it would be easier to see. For some reason, I thought I should try it out again.
Guess what – it worked and successfully uploaded the code. I’m guessing the connections were interfering with the SPI signals. So that’s that problem solved.
As I could program the ESP8266 and AVR still connected using the bootloader, I think I just have to continue that way. There is still the problem if the 12MHz crystal is OK and if the Adafruit Pro Trinket bootloader works for me, but that is another day.
Many thanks for your help,
Thanks for taking the time to look into this.
I was originally worried about the 12MHz, especially as many commercial 3.3V boards all use 8MHz. Doing a deep delve into the spec I found this diagram showing the safe operating frequency envelope. I annotated this a bit and it looked like the highest frequency for 3.3V was 13.5MHz. I was also encouraged to see the Adafruit Pro Trinket used 12MHz.
To be honest, I still not 100% sure, so maybe I’ll order an 8MHz crystal just to be sure,
I am glad you figured out your issue and fixed it; thank you for letting us know.