Sunday, 29 May 2016

StlinkV2 wiring diagram


RED = VDD
GREY = SWDIO
ORANGE = SWCLK
YELLOW = NRST
BLACK = VSS




Inquire IDE

Inquire IDE is a custom IDE for my custom projects.

Specifications:
  • Qt Quick and Javascript for interface
  • C++ for back end processing
  • Use arm gcc compilers
  • Use rust/zinc compilers
  • Git version control
  • JSON for config files
Supported boards and languages:
  • STM32L1 discovery
    • C
    • Rust/zinc
  • Project Garbanzo
    • C
    • Rust/zinc

Sunday, 15 May 2016

USB Design


Some specifications of USB can be complicated as USB has a high data rate.



USB 2.0 low speed (small distances)


Data rate is 1.5 Mbit/s. Doesn't need impedance matching and same trace lengths for small distances. Requires a pull up resistor for USB_DM. Some MCUs have pull up resistors from USB_DM (D-) to VDD (voltage of MCU).

USB 2.0 full speed (small distances)

Data rate is 12 Mbit/s. Doesn't need impedance matching and same trace lengths for small distances. Requires a pull up resistor for USB_DP. Some MCUs have pull up resistors from USB_DP (D+) to VDD (voltage of MCU).


USB 2.0 full speed/low speed (long distances)

Here you need to consider trace length and impedance matching. Design steps:
  1. Add ground plane bellow traces (if ground plane not available add a VDD plane)
  2. Find the minimum lengths of D+ and D- traces to MCU
  3. Take the longest of the lengths and make length of the traces match
  4. Use micro-strip calculator to calculate impedance
  5. Adjust width of trace for the impedance between D+ and D- is 90 ohms
  6. Adjust size of ground plane for the impedance of D+ to ground is 30 ohms and D- to ground is 30 ohms









Friday, 13 May 2016

General PCB design process

Documentation for general PCB design process
  • Set design requirements
  • Pick components
  • Read datasheets
  • Design circuit
  • Check footprints
  • Check layout of PCB
  • Use DRC and signal integrity tools
  • Review circuit design
  • Make footprints
  • Check layout of PCB
  • Review footprints dimensions
  • Do a preliminary placement of components
  • Read all signal specifications
  • Place traces for signals
  • Place traces for power supply
  • Place traces for ground
  • Use DRC and signal integrity tools
  • Review PCB design

Designing for STM32 ARM

There are a few thing to worry about designing STM32 circuits/PCBs. The main ones are power supply,ground, reset, boot pins, SWD, crystals, analog side, USB, and boot loaders.


Power supply


Power is provided with VDD (digital). The voltages are typically around +3.3V. Use decoupling capacitors (example: 0.1uF) near STM32. Place the STM32 close to power supply. Use a large trace for power. Read datasheet for more information.


Ground

Ground is provided with VSS (digital). Use a ground plane or a large trace for ground.


Reset


Reset pin is NRST. Typically the pin is connect to VDD with a pull-up resistor. To reset the STM32 set NRST low. Add a decoupling capacitor (example: 0.1uF) near NRST.


Boot pins


Boot pins are typically BOOT0 and BOOT1. Functionality of boot pins.

BOOT1BOOT0Boot mode
X 0User Flash memory
0 1 System memory (boot-loader)
1 1Embedded SRAM

Add a pull-down resistor (example: 1K ohms) from boot pins to VSS.


SWD


Here are the pins for SWD (Serial debug wire):
  • VDD power supply
  • VSS ground
  • SWDIO
  • SWCLK
  • NRST reset
SWD is used to flash and debug STM32. The STM32 doesn't have flashing/debugging capabilities by itself. STM32 requires STLinkV2 to flash and debug STM32. See SWD design blog post for more information.


Crystals


Some STM32 requires HSE (high frequency external oscillator) and LSE (low frequency external oscillator) . Pin names have OSCIN and OSCOUT. Steps to design:
  1. Find if HSE or LSE or both is required in the datasheet
  2. Find acceptable range of frequencies for crystals (use STM32CubeMX)
  3. Select crystals from component distributor
  4. Get load capacitance of crystals
  5. Find stray capacitance of PCB
  6. Use load capacitance of crystals to calculate external load capacitors
CL = ((C1 x C2) / (C1 + C2)) + Cstray

Where CL = load capacitance of crystal
C1 = external load capacitor
C2 = external load capacitor
Cstray = stray capacitance of PCB

Analog side


The pins are VDDA and VSSA. They are analog power supply and ground. Design steps:
  1. Find if STM32 has VDDA or VSSA or both
  2. If they exist then they must be connected properly
  3. Find tolerances for VDD
  4. Design filter circuit using an inductor and capacitor from VDDA to VDD
  5. Separate VDDA and VDD
  6. Separate VSSA and VSS
  7. Use star ground configurations to connect planes of VSSA and VSS 
  8. VDD and VSS must not be noisy 

 

USB


USB uses USB_DM and USB_DP pins. For USB 2.0 low speed/full speed impedance matching and trace length doesn't matter. Some STM32 have pull up resistors from USB_DP to VDD. See USB page for more information.


Boot loaders



Boot loaders are used to load user flash. Some STM32 have boot loaders builtin from the factory. Use STLinkV2 or STM32 DFU to flash boot loader.



Unused pins


Unused pins can be configured using the following way:
  • Not connected to anything. Make pin output.
  • Connect to VSS using a pull down resistor.
  • Connect to VDD using a pull up resistor.