Prerequisite: Analog Electronics 模擬電路, Digital Electronics 數字電路
One thing to keep in mind is that unlike software learning where you can just watch Youtube videos online and code along it, the learning method is different for hardware. You will find yourself reading text documentations and product specifications, protocol standards, measuring voltage, and asking people in the community a lot. To learn this skill, watch Hardware Wallet Research Series: #1, #2, #3, #4, #5, #6, #7
Totorial Series:
Units:
Current (I): how many electrons per time measured in Ampere (A, coulomb / second)
Power (P): energy per time measured in Watt (joule / second)
Voltage (V): energy per electron V = I \cdot R measured in volt (watt / ampere or joule / coulomb)
Resistance (R): (energy / time / electron^2) how much energy per electron per time measured in ohm (volt / ampere)
Concepts: PCB Basics
打樣: 小批量打造 PCB 樣品.
淚滴: 在元器件旁邊的電子線路半徑較大, 如同眼淚
封裝: 元器件露出針腳的位置
鋼網: 錫膏網, 紅膠網
回流焊: 開孔在焊盤
波峯焊: 開孔在焊盤之間
晶振: 依靠電氣石, 石英, 壓電陶瓷的 壓電效應
電感: 電感
電容: 滤波电容是怎么滤除噪声的,旁路电容和去耦电容有什么区别, 电源中的电容大小如何确定?过来人告诉你,得计算!, 去耦电容(2)- 电容该如何选用?, 殊途同归,从两个角度解释电容退耦原理(超透彻)
Capacitor: smooth out signal
Resistor: resist voltage
Diode: one-way gate, stripe is negative
LED (Light Emitting Diode): longer is positive
Transistors: electrical-controlled gate
SoC: system on chip
IC: integrated circuit
Cap: capacitor
ESD: electrostatic discharge
Footprint: the physical structure associated with electronic symbols
Quiescent Current: current during inactivity
Simple Electronics Basics Series
PCB has layers:
Silkscreen (White): drawings
Surface Finish (ENIG, Gold): protection of expose copper for preventing ionize
Solder Mask (Green): protection of copper on all surface of PCB except exposed mounting point
Substrate (FR4, Brown): insulation
Q: Why are there so many capacitors added in parallel rather than just one big capacitor?
A: Caps are located close to each digital IC, or small set of such ICs, to act as local reservoirs to smooth out the rapidly fluctuating current demands of such ICs. This prevents those rapidly fluctuating currents from causing fluctuating voltages on longer supply wires (PCB traces) and possibly disrupting other chips connected to those supply wires.
In some instances you will also see a large cap parallel with a small cap right next to it. The large cap provides a large reservoir, but has a significant internal resistance, so doesn't respond as quickly as a small cap can. So together the two caps can respond quickly and provide a large reservoir.
Real capacitors have both some internal resistance and inductance in series with their "ideal" capacitance. The effects are larger with larger-value capacitors, and vary with capacitor material and construction. For the current discussion, both these non-ideal characteristics act to slow the speed with which the capacitor can respond.
A: These caps are used as "decoupling" capacitors. Even though they appear like they're all next to each other, they will be located (often in pairs) on the circuit board next to power pins of digital IC's.
Unlike analog circuitry, a digital circuit uses power in short, fast bursts. All traces or wires have some inductance, which prevents the current from changing as quickly as the IC needs it. This causes two problems: The voltage fluctuates at the input pin, and the rapidly-changing current causes the traces to radiate electrical noise.
A decoupling capacitor provides two main functions: 1. The first function is to prevent these two problems. It acts as a small power buffer right at the IC, and can provide the necessary rapidly-fluctuating currents. Since they are located right next to the IC's, there are no long traces to act as noise generators. 2. The second function is to act as a filter, dampening noise seen from the outside of the chip. This is where the multiple values of capacitors come into play. The capacitors have some small parasitic inductance, also. Each capacitor you add creates an LC filter. Each different capacitor value, combined with the parasitic inductance, filters a different range of frequencies. It is common to see a 100pF next to a 0.1uF cap at each power pin. This combination has a favorable filtering bandwidth.
So, even though you could use one large capacitor to match the nominal bus capacitance, you would lose the decoupling benefits.
The names are confusing:
USB 3.2 Gen 1 is USB 3.0. It has a maximum throughput of 5Gbps
. This is also known as SuperSpeed USB.
USB 3.2 Gen 2 is USB 3.1. It has a maximum throughput of 10Gbps
. This is also known as SuperSpeed USB 10Gbps
.
USB 3.2 Gen 2×2 is USB 3.2. It has a maximum throughput of 20Gbps
. This is also known as SuperSpeed USB 20Gbps
.
Before USB Type C, all connectors has a host end and a client end, which lead to the design of different type of connector on different end to avoid confusion. However, both side Type C can either be host or client (dual role), therefore Type C is commonly made with Type C on both side.
Don't confuse USB protocols (like 2.0 and 3.0) with USB connector (USB-C, USB-A). But USB-C has protocol: 3A, 60W, dual role. Knowing a physical wire has a USB-C connector doesn't tell you what protocol the physical wire supports. A full-featured USB-C should support USB 3.1 Gen 2 and compatible with USB 2.0.
Power Delivery (PD): support 5A, 100W when the device requires it. Note that not all USB-C support PD.
Alt Mode: Alternate Mode is a mechanism that uses a USB Type-C shape port and cable to send a signal of another specification. This allows people to make different flavors of USB-C cable and port to send non-USB signal as well as USB-signal through USB-signal. Only USB-C can potentially support an Alt Mode and one USB-C cable or port is limited to have one of the "flavor". You can think of a port or a cable having one of the "flavor". A "flavor" can also be thought as a bundle of supporting protocols. For example, a cable with the Thunderbolt "flavor", which bundles USB, DisplayPort, Thunderbolt protocol, can be plugged into ports with original USB flavor, or DisplayPort flavor, or Thunderbolt flavor. The cable also has type Passive or Active.
While each protocol have their native cable (for example: USB 3.2 protocol uses USB-C, display port protocol uses display port), Thunderbolt protocol's native cable uses USB-C exclusively. Thunderbolt 3-port cable is "one of many variations of USB Type-C port cables"
Note that all Thunderbolt Alt Mode support DisplayPort Alt Mode (except for DisplayPort 2.0) as shown in chart above.
"VBUS" is the USB bus voltage. It's nominally 5V (give or take 5%). You can connect it to the VCC on a 5V tolerant device. Sprinkle some decoupling capacitors (to filter signal) around it and your project can be bus powered. If you're self-powered, there's no need to connect VBUS to anything. Does your device has a use case where it's powered but not plugged into USB? If not, I'd put a weak pull-down on reset# and have a stronger pull-up tied to VBUS. That way the device gets a reset when it's plugged in. https://www.reddit.com/r/AskElectronics/comments/5dn0nf/what_is_vbus_in_this_diagram/
There are various symbol in the library for USB-C. For example TYPE-C-31-M-12
refers to Type-C male port (maybe 31 means with USB 3.1 protocol) and 12 ports.
If a cable only support UBS2, not beyond 5V and not beyond 3A, then it may not be electronically marked. Otherwise, all cable need to be electronically marked.
An Electronically Marked Cable Assembly (EMCA) is a USB Type-C cable that uses a marker chip to provide the cable’s characteristics to the DFP. The electronic marking is accomplished by embedding a USB PD controller chip into the plug at one or both ends of the cable. These marker chips operate from VCONN power (or VBUS power as per the cable design). VCONN is a low voltage rail operating between 2.7 Volts and 5.5 Volts but is limited to 1 Watt of power. VBUS can be a high voltage rail up to 20 Volts. While marker chips operating off of VBUS can take advantage of more power a high voltage marker chip can also be more expensive. For this reason, most marker chips are powered by VCONN.
For legacy device using USB2.0, the following connection should be made.
UBS connection needs impedance matching and sometimes 1.5k Resistor for indicate full-speed device. However, these two are incorporated in most STM32 chips.
封装 | 尺寸 | 功率 | 电阻耐压值 V |
---|---|---|---|
0201 | 1/20W | 25 | P2P |
0402 | 1.0mmx0.5mm | 1/16W | 50 |
0603 | 1.6mmx0.8mm | 1/10W | 50 |
0805 | 2.0mmx1.2mm | 1/8W | 150 |
1206 | 3.2mmx1.6mm | 1/4W | 200 |
1210 | 3.2mmx2.5mm | 1/3W | 200 |
1812 | 4.5mmx3.2mm | 1/2W | 200 |
2225 | 5.6mmx6.5mm |
Soldering is to make connections by melting the right amount of solder to make bound with copper.
Flux: Flux is to remove oxidized layer of copper wire so that solder can directly bound with copper instead of staying on the surface of oxidized layer. The remaining flux can be removed from PCB by washing with Isopropine alcohol.
Usually we use rosin-core solder (don't use plumbing-core flux or acid-core flus as they corrode parts), note that rosin is also poisonous
Flux is helpful for soldering tiny parts of PCB
There are flux pen, flux paste in tube or flux paste in case
Solder: thin solder is good as it gives you more control of amount of solder you are applying. Typically solder comes with flux inside the wire.
Lead Solder: lower melting point, but bad for health
Lead-less Solder: higher melting point, but good for health
Cleaning:
use isopropyl alcohol to clean PCB with brush
brass (or sponge with water) to clean soldering tip
Temperature: 316~343 Celsius for lead-based solder and 343~371 Celsius for lead-free solder
Protection: leave some solder on the tip if you are not using the tip for a while
Other stuff you might (or might not) need: insulator heat shrink, plate holder, wire cutter or striper, soldering breadboard.
If you prefer unnecessarily long video, watch this (Part 1) and (Part 2)
For more, it is good if you can read The Ultimate Guide to Soldering
If you have multiple PCB boards, you can order a solder paste stencil to help you mount the components on PCB quickly. You must order the stencil with the PCB as the height and holes must match.
There are also machines in CMU TechSpark (and courses) that can mount components for you
Preperation:
Keil5: code IDE. While Keil5 C51 is for STM32, Keil5 MDK is for ARM.
STC-ISP: code transmission
USB to UART Driver CH340_CH341: driver for connecting board to PC
MCU: Micro Controller Unit, including CPU, RAM, ROM, click, ...
8051: The Intel MCS-51 (commonly termed 8051, typically pronounced eight-oh-five-one) is a single chip microcontroller (MCU) series developed by Intel in 1980 for use in embedded systems. So any chip support MCS-51 instruction set is 51-MCU.
A bar on the top of a port means low voltage enabling.
VCC (Volt Current Condenser): 电路的供电电压
5V: high voltage, depletion of electrons with respect to infinit electrons, denoted as 1
in digital signal.
0V: low voltage, plenty of electrons, denoted as 0
in digital signal.
TTL: 5V~0V
GND (COM): Ground CE(OE): Chip Enable, 使能. 芯片的開關.
When we press a button, a raw voltage is sent to a port. Usually, we make the port output 0
on some port and connect LED with the port and GND
to light up the LED. The same goes for LED arrays.
There are two types of connection for LED arrays, we can either share common anode or common cathode (GND).
For display matrix, the circuit is arranged in the following manner (similar to keyboards)
When there is lack of pins to accurately identify the LED or input button, we can scan the port (only detecting or outputing a certain row or column)
掃描: 減少 I/O
口
數碼管掃描: 顯示第 1 位 -> 顯示第 2 位 -> ... 顯示第 n 位 -> 顯示第 1 位 -> ...
矩陣鍵盤掃描: 讀取第 1 行 -> 讀取第 2 行 -> 讀取第 n 行 -> 讀取第 1 行 -> ...
STC89C52
has built-in internal clocks (T0, T1, T2) where T0 and T1 clocks are in all traditional 8052
and T2
is specific to STC89C52
.
Clock: clock is counter, you can command the clock to interupt after some time.
There are 4 modes for STC89C523
T0 and T1 clocks:
Mode 0: 13 bit clock
Mode 1: 16 bit clock (common)
Mode 2: 8 bit automatic reload
Mode 3: two 8 bit clock
How clocks work in hardware: SySclik
(晶振週期) provide clock pulse to clock and is received by two counters. One counter count the number of low voltage and the other count the number of high voltage. They share a number of bits (16 in Mode 1). When the counters overflow, interrupt is triggered. When the input is connected to port instead of SySclik
, then the clock becomes a counter.
If the CPU clock is 1 Hz, then the voltage go high and low for 1000000 times.
There are limited amount of interuption hardware in STC89C523
(OutsideInterrupt0
, ClockInterrupt0
, OutsideInterrupt1
, ClockInterrupt1
, SerialPortInterrupt
, OutsideInterrupt2
, OutsideInterrupt3
) where the last two are not common in typical 8051
. There are also limited number of priority int.
This article: 上拉电阻, 下拉电阻, 强上拉, 弱上拉, 强下拉, 弱下拉 and this article explains the concept.
Strong pull-Up is the action of increasing the voltage of a point by connecting the point with higher voltage through a low resistor. This way, the voltage of the point is nearly identical as the voltage of the added voltage. Weak pull-up is the action of increasing the voltage of a point by connecting the point with higher voltage through a high resistor. This way, the voltage of the point is only increased a bit. Pull-down shares the same idea as pull-up but for the purpose of decreasing the voltage of a point.
Serial Port is a port to transmit byte information between two device.
The serial port looks like VGA port but it only has 9 pins. Do not confuse it with VGA. Many old computers have this port. There are serial port to usb or even bluetooth adaptor.
The easiest connector with serial port only involves 4 pins. VCC, TXD, RXD, GND
for device 1 and VCC, TXD, RXD, GND
for device 2. Note that we cross connect TXD
and RXD
. (Be careful on PCB schemetic) The TXD
stands for Transmit Exchange Data and RXD
stands for Receive Exchange Data.
We could ignore one of
TXD, RXD
connection if the data flow is one directional.
There are multiple protocol we can use
TTL protocol: +5V
represent 1
and 0V
represent 0
.
RS232 protocol: [-3V, -15V]
represent 1
and [+3V, +15V]
represent 0
RS485 protocol (Differential signalling): The voltage difference is [+2V, +6V]
represent 1
and [-2V, -6V]
represent 0
(or inverted). Note that this measures voltage difference and must require 2 wires.
The reason we use Differential Signalling is that it can transmit beyond 10 meters or wire and possibly 1000 meters without much disturbance. This protocol is commonly used in USB.
Other pins like DTR
and RTS
are pins that control data flow (not supported by 8051
)
Half Duplex: can send and receive, but not at the same time. Usually 1 pin. Full Duplex: can send and receive at the same time. Usually 2 pins. Single Duplex: only one way transmission by 1 pin (or bluetooth wireless etc...)
Async: both device obey their own transmission rate Sync: both device obey the same clock cycle, usually needs a clock pin.
There are a few more protocols: and also CAN
(in cars), USB
Name | Pins | Transmission | Comments |
---|---|---|---|
UART | TXD, RXD | Full Duplex, Async | Point to Point Transmission |
PC | SCL, SDA | Half Duplex, Sync | Multiple Device attach on Main Line |
SPI | SCLK, MOSI, MISO, CS | Full Duplex, Sync | Multiple Device attach on Main Line |
1-Wire | DQ | Half Duplex, Async | Multiple Device attach on Main Line |
UART is serial port // QUESTION
STC89C52
has 4 modes for UART
:
Mode 0: synchronous register
Mode 1: 8 bit UART, can change Baud (common)
Mode 2: 9 bit UART, cannot change Baud
Mode 3: 9 bit UART, can change Baud
Baud Bit: the rate of transmission sampling Verify Bit: Hamming Code Stop Bit: divide byte to byte
We can use chips like 74HC695
to extend the number of IO ports. It is esstentally a register that take sequential input and converted to synchronous signal.
The way it works is that we send bit information to one port and then move the all information by one slot (and reset). Once all data is there, we batch send them.
There are following peripherals on the chip:
NVIC: 嵌套向量中斷控制器 (in chip)
Sysick: 定時器 (in chip)
RCC: 復位和時鐘控制
GPIO: General Purpose IO
AFIO: 複用 IO
EXTI: 外部中斷
TIM: 定時器
ADC: 模數轉換器
DMA: 內存訪問
USART: 同步/異步串口通信
I2C: I2C 通信
SPI: SPI 通信
CAN: CAN 通信
USB: USB 通信
RTC: 實時時鐘
CRC CRC 校驗
PWR: 電源控制
BKP: 備份寄存器
IWDG: 獨立看門狗
WWDG: 窗口看門狗
DAC: 數模轉換器
SDIO: SD 卡
FSMC: 可變靜態存儲控制器
USB OTG: USB 主機接口
Some images and text are from STM32固件库(标准外设库)入门学习 第一章 STM32简介
供电电路: 在3.3V和GND之间有滤波电容C4、C5、C6、C7,这个电容可保证供电电压的稳定,在设计电路的时候,只要有供电,都会习惯加上几个滤波电容。 晶振电路: 8MHz晶振接到5、6号引脚,还需要接两个20pF的电容,作为启振电容,电容另一端接地。
复位电路: 复位电路是一个10k的电阻和0.1uF的电容组成,用来给单片机提供复位信号,接7号引脚,NRST为低电平复位的,复位电路在上电的瞬间,电容是没有电的,电源通过电阻开始向电容充电,并且此时电容呈现的是短路状态,NRST引脚为低电平,当电容逐渐充满电时,电容就相当于断路,此时NRST就会被上拉为高电平。上电顺间的波形就是先低电平,然后逐渐高电平。电路左端有K1按键,提供一个手动复位,按下K1电容被放电,并且NRST引脚也通过按键被直接接地了,相当于手动产生了低电平复位信号。按键松手后,NRST又回归高电平,此时单片机就从复位状态转为工作状态。平时在电子设备上也会看到这个,一般是一个小孔,当设备死机并且不方便断电重启时,就可以拿一个针去戳一下,就可以使设备复位了。
启动配置电路: H1相当于开关的作用,拨动开关就可让BOOT引脚选3.3V还是GND,在最小系统板上使用的是跳线帽充当开关的功能,当跳线帽在左边两个引脚时,就相当于接GND,插在右边两个引脚时,就相当于接3.3V。这样就可以配置BOOT的高低电平。自己设计电路时,可以接一个拨码开关。
Read Manual:
In 6.3.15 NRST pin characteristics
, you can find inctrustion on how to configure NRST
pin. Table 56. NRST pin characteristics
tells you the value for pull-up resistor R_{PU} is 40 k\Omega. And Figure 25. Recommended NRST pin protection
tells you how to add protections.
In Table 24. General operating conditions
, you can find voltage and temperature requirement for each pin during operation.
In Table 14. STM32F072x8/xB pin definitions
, you can find all pin definitions, very useful for identifying I/O pins.
In Figure 13. Power supply scheme
, you can find how to power up the chip.
In Figure 17. Typical application with an 8 MHz crystal
you can find typicall configuration for external oscillator.
There isn't detailed documentation for BOOT0
, watch this video instead.
In Table 4-25 Sink CC Termination (Rd) Requirements
of USB Standard you can find value for Rd
resistor and in Figure 4-30 Source to Legacy Device Port Functional Model
you will find USB 2.0 schemetic.
In Table 50. ESD absolute maximum ratings
tells you about protestion from ESD. However, you don't want them to be used since they are the last layer of protection and you should protect the peripherals from ESD.
If you use high frequency signal wires (like USB), Table 70. USB electrical characteristics
gives you output driver impedance and it says "No external termination series resistors are required on USB_DP (D+) and USB_DM (D-); the matching impedance is already included in the embedded driver."
When purchasing parts, go to LCSC-EN as the chinese version sucks.
Here is a video explaining STM32CubeIDE and you can download it here. You can also thoose STM32CubeMX but it does not have a debian version.
There are a few protocol for between-device communication
UART: can be half-duplex or full-duplex. Software UART serial can be configured with any pin/
I2C: old, slow, but master can speak to multiple slave
SPI: fast, full-duplex, SD-Card is SPI.
CAN (not supported by QMK): slow, allow
Here is a blog post clarify CAN, I2C, JTAG, SPI, SWD, and UART
There isn't a consensus on how to connect SWD pins. You can define how many pins as you want and they are connected by jump wire.
These protocols are used for additional drivers in addition to having one MCU. Usually MCU flash is done with USB DFU protocol used in the STM32 bootloader. DFU stands for Device Firmware Upgrade and it only allows you to flash a new device (Getting started with STM32 built-in USB DFU Bootloader) and cannot be used for debugging purposes. Flashing a device with USB DFU involving set
BOOT0
to1
and flash using USB connection and then setBOOT0
to0
beforeRESET
. You need to have one of the above protocol (and port) open for debugging purposes as you can't debug with USB DFU. Specific tools like JTAG, ST-Link, or USB-to-UART is needed.
Many keyboards in the QMK Firmware repo are split keyboards. They use two controllers: one plugging into USB
, and the second connected by a serial
or an I2C
connection over a TRRS
or similar cable. ARM split supports most QMK subsystems when using the ‘serial’ and ‘serial_usart’ drivers. I2C slave is currently unsupported by QMK. Both sides must use the same MCU family.
If you want to make a split cable, see Required Hardware
For flashing firmware into STM32, see Boot Mode
section.
At startup, the boot pin and boot selector option bit are used to select one of the three boot options: - boot from User Flash memory - boot from System Memory - boot from embedded SRAM
The boot loader is located in System Memory. It is used to reprogram the Flash memory by using
USART
on pinsPA14
/PA15
, orPA9
/PA10
orI2C
on pinsPB6
/PB7
or through the USB DFU interface.
Some MCU does not have BOOT1
pins. You might only be able to set BOOT1
using software.
Here is a introduction to linear regulator (LDO)
Types of Regulator:
LDO (Low Dropout Regulator): power dissipate as heat, use when low power and low current
Switching Regulator: high efficiency, generate noise voltage, not recommended in analog circuits
Common LDO:
AP1117
: inexpensive, high quiescent current (15mA)
AMS1117
: inexpensive, high quiescent current (15mA)
MCP1700t-3302
: pricy
AP2127
: 70uA quiescent
XC6206
: 7uA quiescent (XC6206P332MR
for 3.3V)
Sometimes scottky diode (instead of silicon diode as it doesn't impact voltage as much) can be used to prevent backflow of power when user connected to the wrong end. Note that scottky diode might not be able to block all current, 20mA will leak through as compared to silicon diode, but it is sufficient for reverse voltage protection. Absolute maximum rating is normally set as 10V greater than peak reverse voltage, peaking higher voltage rating will sacrefice efficiency.
Power protection (ESD/TVS) and filtering can get very complicated and often involves:
dedicated chip
resistors
capacitors
diodes
Compare ESD and TVS, we know that ESD is protection for human electrical discharge, and TVS is protection for electrical surge. They appear on schemetic as a inverte-connected diode. Such protection is needed at connection to USB since it USB provides both power and signal.
TVS: here is how to choose TVS
ESD: here is how you wan to design circuits for pin's ESD protection
Q: So a bit of an odd question, I want to replace all the various bits on a Mysterium with a black pill (sans diodes, switch, etc) If I run lines from PA11, PA12 (Data + and Data -) as well as GND and VCC, and use an external USB port, will I need to add a resistors on the data lines or would that all be handled by the Black pill itself? A: STM32 chips don't need impedance matching resistors on USB data lines, so you should not need to add anything extra (although you may want to add things like a fuse and ESD protection). And if you will be using a Type C port, you will need two 5.1k resistors on CC pins (but they won't be connected to the blackpill).
You should check the manual to see if your chip has integrated impedance matching for USB.
Here is an advanced circuit for reset and boot. The circuit make use of MOSFETs to act as a voltage-controlled switch. When the human-controlled botton is pressed, the BOOT
pin gets powered, and then once powered, the NRST
pin is powered by the internal MCU, therefore disconnect BOOT
from 3.3V
. Once botton is released, NRST
is pulled down by GND
and reset the MCU.
Here is a good Routing Tutorial. And here is a tip video for PCB routing
PCB Design Rules
No 90 degree connection (or via) for signal wire
Filter capacitors around power consumption
Power protection near power source
Ground plane right below top trace plane
Use top trace plane as your main trace routing
Instead of buying an ST-Link, we can buy a developmen board.
Follow this guide so that you know to light up LD2
, you need to set A5
high. You can use STM32CUBEIDE
and run debug configuration. In C/C++
application set your flashing .elf
file and hit run to flash your board with ST-LINK S/N
enabled and scan automatically.
Run
Run Configuration
STM32 C/C++ Application
C/C++ Application
, give path to your .elf
fileDebugger
, Misc -> Log to file
, enable and select a log file (otherwise will result in device not found error)Debugger
, GDB Server Command Line Option -> Interface
, check ST-LINK S/N
and hit Scan
.Assume you have just purchased ST-Link and soldered your board, here is what you need to do to debug:
STM32CUBEIDE
, and configure the pins you want to test by clicking the pin and select GPIO_OUTPUT
while
loop, add the code that looks like this (names may be different) while (1)
{
/* USER CODE END WHILE */
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_10);
HAL_Delay(500);
/* USER CODE BEGIN 3 */
}
Here are a list of video explaining the concept of impedance matching
Here is a trace impedance calculator for signal and here is a trace width related to current consumption and here is differential impedance calculator (jlc
uses 4.5 Dielectric Constant in FR4
with option of standard 1.6mm or 63 mil board and 1oz of copper is 35\mu m thick or 1.4 mils). Note that you should consider manufacturer's capability when using design rules. However, Altium Designer is the only option for calculating trace width for coplanar differential pairs (read article).
For hand-calculation of Edge-coupled coplanar, see this stackoverflow
Once you settle down your design, check out this good video as it will run you through the entire process of pcb design with small caution (or nice to have) details like impedance matching and power protection.
To connect GND
together, you fill out copper in all planes. For 4 layers, it is common to have Signal, GND, POW, Signal
stackup. However, there isn't a consensus on whether you should pour GND
for the top layer in 2-layer PCB.
This is for:
lower impedance to ground
better heat dissipation
some protection on EMC
better quality in manufacture
Note that for digital signal, copper pour is good. But it might be bad for analog signal due to electromagnetic coupling. Therefore not all pcb needs copper pour.
There are two ways to do copper pour
Copper All Over The Place: just normal copper pour. It has better EMC protection but might sensitive to expansion/contaction due to temperature change.
Grid pour: Poor EMC protection, but not sensitive to temperature during manufacture.
Before Finish Design: - vias in chip for heat dissipation - rounding edge - testing pad with exposed copper - screw holes - pretty drawing and logos - pin labels
Table of Content