Custom PCB - Issue During Bootloading - Page 1
Forum section: electronics / beginners

author: dreece2498
author_rank: Contributor
timestamp: December 22, 2022, 04:57:24 pm
content: I created a PCB to display my initials (posted this on reddit as wellhttps://www.reddit.com/r/AskElectronics/comments/zspo2l/custom_pcb_issue_during_bootloading/). At first, the bootloader bootloaded and I was able to upload my code to control the colors of the LEDs but now for some reason it's not working. I'm using usbasp to program it and I have the board selected as Arduino Leonardo since I'm using an Atmega32u4 (using Arduino to program the chip). My question is, why is it suddenly no longer programming? The error message is as follows:Sketch uses 6688 bytes (23%) of program storage space. Maximum is 28672 bytes.Global variables use 472 bytes (18%) of dynamic memory, leaving 2088 bytes for local variables. Maximum is 2560 bytes.C:\Users\ricci\Documents\ArduinoData\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude -CC:\Users\ricci\Documents\ArduinoData\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf -v -patmega32u4 -cusbasp -Pusb -Uflash:w:C:\Users\ricci\AppData\Local\Temp\arduino_build_637753/RGB_Control_Code.ino.hex:iavrdude: Version 6.3-20190619Copyright (c) 2000-2005 Brian Dean,http://www.bdmicro.com/Copyright (c) 2007-2014 Joerg WunschSystem wide configuration file is "C:\Users\ricci\Documents\ArduinoData\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"Using Port : usbUsing Programmer : usbaspAVR Part : ATmega32U4Chip Erase delay : 9000 usPAGEL : PD7BS2 : PA0RESET disposition : dedicatedRETRY pulse : SCKserial program mode : yesparallel program mode : yesTimeout : 200StabDelay : 100CmdexeDelay : 25SyncLoops : 32ByteDelay : 0PollIndex : 3PollValue : 0x53Memory Detail :Block Poll Page PolledMemory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------eeprom 65 20 4 0 no 1024 4 0 9000 9000 0x00 0x00flash 65 6 128 0 yes 32768 128 256 4500 4500 0x00 0x00lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00lock 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00Programmer Type : usbaspDescription : USBasp,http://www.fischl.de/usbasp/avrdude: auto set sck period (because given equals null)avrdude: error: program enable: target doesn't answer. 1avrdude: initialization failed, rc=-1Double check connections and try again, or use -F to overridethe selected serial port Double check connections and try again, or use -F to overridedoes not exist or your board is not connectedthis check.avrdude done. Thank you.The code:#include <IRremote.h>#include <Adafruit_NeoPixel.h>#include "WS2812_Definitions.h"int IRpin = 10;IRrecv IR(IRpin);decode_results command;int delaytime = 1000;String myCommand;int LEDPIN = 6;int NUMPIXELS = 24;int counter = 0;float defact = 1;int j;int i;Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, LEDPIN, NEO_GRB + NEO_KHZ800);void setup() {Serial.begin(9600);IR.enableIRIn();strip.begin();}void loop() {strip.setPixelColor(0, strip.Color(140,127,0));strip.setPixelColor(1, strip.Color(140,127,0));strip.setPixelColor(2, strip.Color(140,127,0));strip.setPixelColor(3, strip.Color(140,127,0));strip.setPixelColor(4, strip.Color(140,127,0));strip.setPixelColor(5, strip.Color(140,127,0));strip.setPixelColor(6, strip.Color(140,127,0));strip.setPixelColor(7, strip.Color(140,127,0));strip.setPixelColor(8, strip.Color(140,127,0));strip.setPixelColor(9, strip.Color(140,127,0));strip.setPixelColor(10, strip.Color(140,127,0));strip.setPixelColor(11, strip.Color(140,127,0));strip.setPixelColor(12, strip.Color(140,127,0));strip.setPixelColor(13, strip.Color(140,127,0));strip.setPixelColor(14, strip.Color(140,127,0));strip.setPixelColor(15, strip.Color(140,127,0));strip.setPixelColor(16, strip.Color(140,127,0));strip.setPixelColor(17, strip.Color(140,127,0));strip.setPixelColor(18, strip.Color(140,127,0));strip.setPixelColor(19, strip.Color(140,127,0));strip.setPixelColor(20, strip.Color(140,127,0));strip.setPixelColor(21, strip.Color(140,127,0));strip.setPixelColor(22, strip.Color(140,127,0));strip.setPixelColor(23, strip.Color(140,127,0));strip.show();}My biggest mistake with this board originally was using a 1.27mm pin header instead of a 2.54mm one. The thing is though, my code was working, at least for setting the LEDS to one color. This board was also supposed to use a remote and be controlled by the IR receiver on the front, however for some reason D25 is always on when it receives power, which it shouldn't since it should only turn on when the remote is pressed.So my main questions are as follows:Why is the USBASP no longer uploading the code if it was working fine and boot loaded and was programmable originally?Will I be able to control the LEDs with an IR remote from an Arduino kit? I know how to write the code for it and tried testing it when it was uploading, but it wasn't working.Since the chip is already boot loaded, can I program and power the PCB via my USB-C connector I put on there? I connected it to D+ and D- with a differential pair.What is causing the D25 to be powered on even when I'm not pressing an IR remote button?Also how do I upload my schematic and wiring pictures? Completely new to this forum and have no idea how to do it.

author: CountChocula
author_rank: Unknown
timestamp: December 22, 2022, 06:35:42 pm
content: Howdy!You can upload your schematics by expanding the “attachment and other options” tab under the text input box when you type in a new message. Looking them over on your Reddit post, I don't see anything obviously wrong with the ICSP connection, though it looks like you've had to bodge a bunch of wires, so if thisusedto work and now doesn't anymore, I'd double check that you haven't accidentally shorted anything out, or fried any of the components. Perhaps go through a process of elimination: check that your ICSP programmer works with another MCU, and, if you have access to an oscilloscope, that signals are getting to the right places, etc.As far as the IR sensor goes, if you look at thedatasheet, you will see that the output is open collector with an internal 32kΩ pull-up resistor connected to the positive rail. Assuming that I'm reading that correctly, this means that the output will be normally high and be pulled low by the demodulator when it receives and decodes an IR signal. If you want the LED to be normally off and turn on when something gets received, you need to invert the signal; since you have all those unused ports on your MCU, I would just connect the LED to one of them and make it flash when you receive data.HTH,—CC

author: dreece2498
author_rank: Contributor
timestamp: December 22, 2022, 06:39:34 pm
content: Thanks! Unfortunately I currently don't have access to an oscilloscope at the moment but I can and should definitely get one, since my projects are getting more complicated. If I did short something, is there a possibility I can program the board through my USB-C connector? Also as for the sensor I see that makes sense, I have it connected to one of the pins on the MCU so I guess I would just have to invert the signal in the code then. I have used the programmer with an Arduino and it seems to work just fine so thankfully I didn't mess up the programmer.

author: CountChocula
author_rank: Unknown
timestamp: December 22, 2022, 07:49:36 pm
content: I am not familiar with that MCU, but it looks like this topichas been discussed beforeon the forums, so maybe that thread will help you.If you do have a short, whether you can program the chip or not depends on where the fault lies… if for whatever reason it's preventing the processor from starting, it might not be possible until you resolve the underlying problem. If you don't have access to a 'scope, you can just try toning out the various connections with a multimeter in continuity mode, and rule out obvious issues, like a connection being shorted to ground or such. Do keep in mind that is just a blind suggestion, though—since I can't actually see your board, I don't know that there is, in fact, anything wrong with it, and so I might just be sending you down a rabbit hole. Good luck!—CC

author: CountChocula
author_rank: Unknown
timestamp: December 22, 2022, 07:52:51 pm
content: BTW, if your MCU did in fact come with the USB bootloader preloaded, it looks like you need to pull PE2 low in order to activate it—which means that you should be pulling ithighduring normal operation. I would try adding a 10k resistor between PE2 and VCC and see what happens. Cheers!

author: sleemanj
author_rank: Super Contributor
timestamp: December 23, 2022, 04:27:01 am
content: > avrdude: error: program enable: target doesn't answer. 1The USBAsp got no response from the target board at all.Easy possibilities:* You have not connected the USB Asp correctly, maybe you crossed MISO and MOSI, maybe you forgot to connect RESET or SCK or GND. Check your connections* You havesomething elseon one of those same pins which is interfering with the communication, make sure to disconnect everything except the USBAsp and then try programming* You accidentally changed the clock selection by an incorrect fuse settingIf the currently loaded program is running then you can probably rule out the last one, but you can use the -Bx option to avrdude (eg -B4) to forcibly slow down the clock rate that the USBAsp operates as, if your USBAsp supports it (not all chinese ones do).Hard possibilities:* You accidentally disabled SPI programming by an incorrect fuse setting. Realistically, just get another chip, not worth your time to fix this if you don't have a HVPP.

author: dreece2498
author_rank: Contributor
timestamp: December 23, 2022, 03:07:55 pm
content: How would I have changed the clock setting? And what do you mean by incorrect fuse setting? As for replacing the chip, I'm assuming you mean take out the Atmega32u4 I currently have on there and put in another one correct?

author: ledtester
author_rank: Super Contributor
timestamp: December 23, 2022, 04:23:13 pm
content: There are three settings (called the low, high and extended fuses) which control various options including which clock source to use and the ability to use SPI programming.Go to this page:https://www.engbedded.com/fusecalc/and select your MCU for how the fuse bits work for your device.And here are some general tips on troubleshooting SPI programming with AVR devices:https://electronics.stackexchange.com/a/638678/