Hello all,
First of all let me preface by saying that this community has helped me tremendously by reading through old threads of other users, testimony being that I never needed to post until now!
I decided to take my Arduino journey a step further and design a custom PCB rocking the ATmega32U4 in order to learn PCB design and have a perfect little board for a personal project.
The context
I want to build a custom temperature and humidity data logger with SDcard, RTC and battery power. I thought it would be nice to make a custom board with all those ICs on there, running 3.3V as to not damage any SDcard.
Since I did want to avoid adding a USB to TTL component, I chose the ATmega32U4, also because I could help myself to the nice schematic of the SparkFun Qwiic Pro Micro - USB-C.
The board
In order to keep cost down, I tried to use through-hole components wherever possible or convenient.
I designed a two-layer PCB in EasyEDA and got it made and partially assembled by JLCPCB.
Please note this is only my second PCB design and the first was very basic, so it was definitely a challenge.
I already know that some things are bad: type and placement of decoupling capacitors, placement and rounting of the crystal, trace width, routing could be much improved in general. I already designed a better version using more SMD components and 4-layers which I'm proud of, but I want to use this bad PCB first if I can since I spent some money on it.
You can see the layout attached to this message (with the nets displayed on each trace/pad). Ground planes are hidden. Also attached is the schematic.
The components
Main items of the BOM and their part numbers at LCSC.com:
- uC: ATMEGA32U4-MUR (C45874)
- Temperature and humidity sensor: Texas Instruments HDC1080DMBR (C82227)
- 3.3V regulator: Diodes Incorporated AP2112K-3.3TRG1 (C51118)
- Amplifier for LED decoupling (not used yet): Texas Instruments LMV358IDGKR (C105242)
- RTC (not used yet): HGSEMI DS1307N (C434596)
- USB-C connector: XUNPU TYPEC-304S-ACP16 (C720630)
- 16MHz crystal: Yangxing Tech X49SD16MSD2SC (C16212)
- RTC crystal: TAE TDXLF-206 32.768KHZ (C145163)
The flashing
Please note that, although I want to use the board on 3.3V in the end, all components support 5V except any SDcard.
After assembling the main parts of the circuit (no LEDs, no OPAMP, no RTC, not RTC crystal, no battery holder and diode) I programmed an Arduino UNO with the ArduinoISP sketch, hooked up the ISP header of my board to the relevant pins on the Uno and flashed the Sparkfun Pro Micro (5V/16MHz) bootloader which succeeded (see logs, abbreviated, below):
avrdude: Version 6.3-20190619
[...]
Using Port : /dev/cu.usbmodem143101
Using Programmer : stk500v1
Overriding Baud Rate : 19200
Reading [...] 100% 0.01s
avrdude: verifying ...
avrdude: 1 bytes of lock verified
avrdude: reading input file "0xCB"
avrdude: writing efuse (1 bytes):
Writing [...] 100% 0.01s
avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0xCB:
avrdude: load data efuse data from input file 0xCB:
avrdude: input file 0xCB contains 1 bytes
avrdude: reading on-chip efuse data:
Reading [...] 100% 0.01s
avrdude: verifying ...
avrdude: 1 bytes of efuse verified
avrdude: reading input file "0xD8"
avrdude: writing hfuse (1 bytes):
Writing [...] 100% 0.01s
avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xD8:
avrdude: load data hfuse data from input file 0xD8:
avrdude: input file 0xD8 contains 1 bytes
avrdude: reading on-chip hfuse data:
Reading [...] 100% 0.01s
avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0xFF"
avrdude: writing lfuse (1 bytes):
Writing [...] 100% 0.01s
avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xFF:
avrdude: load data lfuse data from input file 0xFF:
avrdude: input file 0xFF contains 1 bytes
avrdude: reading on-chip lfuse data:
Reading [...] 100% 0.01s
avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
avrdude done. Thank you.
AVR Part : ATmega32U4
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PA0
RESET disposition : dedicated
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 20 4 0 no 1024 4 0 9000 9000 0x00 0x00
flash 65 6 128 0 yes 32768 128 256 4500 4500 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
lock 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
Programmer Type : STK500
Description : Atmel STK500 Version 1.x firmware
Hardware Version: 2
Firmware Version: 1.18
Topcard : Unknown
Vtarget : 0.0 V
Varef : 0.0 V
Oscillator : Off
SCK period : 0.1 us
avrdude: AVR device initialized and ready to accept instructions
Reading [...] 100% 0.03s
avrdude: Device signature = 0x1e9587 (probably m32u4)
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: reading input file "...Arduino15/packages/SparkFun/hardware/avr/1.1.13/bootloaders/caterina/Caterina-promicro16.hex"
avrdude: writing flash (32762 bytes):
Writing [...] 100% 0.00s
avrdude: 32762 bytes of flash written
avrdude: verifying flash memory against ...Arduino15/packages/SparkFun/hardware/avr/1.1.13/bootloaders/caterina/Caterina-promicro16.hex:
avrdude: load data flash data from input file ...Arduino15/packages/SparkFun/hardware/avr/1.1.13/bootloaders/caterina/Caterina-promicro16.hex:
avrdude: input file ...Arduino15/packages/SparkFun/hardware/avr/1.1.13/bootloaders/caterina/Caterina-promicro16.hex contains 32762 bytes
avrdude: reading on-chip flash data:
Reading [...] 100% 0.00s
avrdude: verifying ...
avrdude: 32762 bytes of flash verified
avrdude: reading input file "0x2F"
avrdude: writing lock (1 bytes):
Writing [...] 100% 0.02s
avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x2F:
avrdude: load data lock data from input file 0x2F:
avrdude: input file 0x2F contains 1 bytes
avrdude: reading on-chip lock data:
Reading [...] 100% 0.01s
avrdude: verifying ...
avrdude: 1 bytes of lock verified
avrdude done. Thank you.
USB connection
Now here's my problem. When I connect the device with the USB-C port to either my MacBook Pro or my Windows desktop computer, the device is not recognized. On macOS, I just don't see the COM port listed. On Windows, the OS warns me that the "USB device is not recognized" and is malfunctioning.
I initially put my finger on the crystal because avrdude reports it "OFF", so I checked it with my cheap BitScope and, although the sampling rate is not high enough by the looks of it, it has a periodicity of 4MHz which could just be what I see with my sampling rate, the real rate being 16MHz supposedly (I captured every 4th point in the signal I think).
Also, since I was able to flash the bootloader, I think it would indicate that the crystal is working as intended.
I would love some help to troubleshoot this, as I really don't have enough experience to do it on my own.
THANKS!