Help with a STM32 based board design - Page 1
Forum section: electronics / general

author: lollandster
author_rank: Contributor
timestamp: June 15, 2019, 06:12:19 pm
content: Hi,First off, I'm sorry if I used the wrong subsection, but this forum has so many of them and several applies.I'm creating a board for interfacing with a sensor through CAN bus. The sensor (ADIS16488A) uses SPI and has a lot of things that can be configured. On the CAN bus side there will be a logger (HBM Quantum MX) that will be recording CAN messages of choice. The board I'm making will be reading sensor data through SPI and sending it to the logger through CAN bus. If done correctly, it will be plug'n'play.This project probably doesn't have any appeal outside my very specific use case, but I'm making it open source so I can use it for self promotion. Everything I do at work is under NDAs (or worse) so I need something to show in job interviews.My discipline is programming, not electronics, so I need some help with the board.I have tried to split the schematic up in modules to make it easier to follow. The full schematic is attached as a pdf.I tried to export a BOM from kiCad, but it didn't do a good job.The first module is the MCU:The MCU is a STM32F042F6P6.Here the bypassing is well covered by the datasheet, so it should be OK. I may have simplified the VDDA slightly since I won't be using the ADC.The crystal was a bit harder since the caps are dependent on the crystal. I chose a TXC 7A-8.000MAAE-T and it says 12pF in the description, so I chose generic 1206 12pF ceramic caps. It was not clear to me if any resistors are needed.See PDF for SWD connector, but that part is tested in a earlier design and should be correct.CAN tranceiver:The CAN transmitter should be easy I hope. The datasheet didn't specify the bypass caps, so I copied two from the MCU.I hope someone can confirm my pin choice on the DB9 connector. Which pins to use for power wasn't very clear in the standard.Power supply:Power supply design is way beyond my skill. I ended up using the Texas Instrument Webench Power Designer and just copying the reference design. I chose one with a huge voltage range just to eliminate the need for any over-voltage protection. It will normally be supplied with 6V and use 250mA@3.3V.C9: C2012X5R1V106K085ACC10: C3216X5R1E476M160AC, this is discontinued, so I have to find a replacement.Any help is appreciated. Constructive criticism is also appreciated, but keep in mind that I'm not a EE and don't intend to become one. I just need a platform for my software.I will start laying out the board tomorrow, hopefully I won't need to make too many revisions.

author: pigrew
author_rank: Frequent Contributor
timestamp: June 15, 2019, 06:35:21 pm
content: Pull down the BOOT0 pin with a resistor. Sometimes you'll need to pull it high in case you flash bad firmware.Add ESD protection to the CAN lines. TCAN332 suggests adding a diode and a pair of capacitors. It also suggests a bit of series resistance on your TXD and RXD lines (usually put next to the transmitting side).R4 NRST pullup may be unnecessary (it has an internal pull-up). Perhaps add a capacitor to GND from nRST (leave position for R4, just maybe don't populate it).

author: lollandster
author_rank: Contributor
timestamp: June 15, 2019, 07:05:43 pm
content: Quote from: pigrew on June 15, 2019, 06:35:21 pm1. OK, I'll do that. Thanks.2. I did see that in the datasheet, but it was marked as optional. If the datasheet had mentioned values for the caps I would have added them... ESD isn't going to be a problem in the intended use case anyway.3. Yes, the datasheet says it's pulled up internally, but I picked up somewhere that it was good practice to pull it up anyways. I can't see how it would hurt anything. How is adding a cap to ground helping me (note that caps are black magic to me)?EDIT: Updated mcu:

author: pigrew
author_rank: Frequent Contributor
timestamp: June 15, 2019, 07:28:44 pm
content: Quote from: lollandster on June 15, 2019, 07:05:43 pmWith respect to 2 and 3, I assumed that you'd be in a noisy environment with transients flying everywhere (like a car). The capacitor would help the reset line stay high in presence of lots of noise.The ESD protection diode would be something like NUP2125 or ESDCAN03-2BWY (low-capacitance ESD protection). The TCAN334 has enough ESD protection that the external protection should only be necessary in the harshest environments... Probably skip the capacitors if you use the TVS diode, as the diodes already add enough capacitance (5 or 10 pF). Any higher than that, and the CAN bus speed would be slowed. The capacitors will be charged by the voltage transient, which takes up the energy reducing the voltage that gets to the IC.

author: lollandster
author_rank: Contributor
timestamp: June 15, 2019, 08:05:21 pm
content: Quote from: pigrew on June 15, 2019, 07:28:44 pmThe intended use-case for this board is inside an EPA protected laboratory. It will not be connected to any car or used in an industrial setting. I want the design to be usable as a reference design for later re-use though. I intend to aim for 1Mbps transfer speed over 5m of good quality shielded cable. That speed was easy for RS422, so I hope it is for CAN too.I took a look at NUP2125 and ESDCAN03-2BWY and they look like something I want to have. I will add one and leave out the caps.Edit: Updated figure with the correct part number.

author: HB9EVI
author_rank: Frequent Contributor
timestamp: June 16, 2019, 10:38:05 am
content: Don't forget a cap on the NRST; ST states to use a cap of ~100n; and to be on the save side, with 10k external pullup you cannot go wrong, the internal is just a weak pullup.depending on the environment you'll have erratic behavior of the mcu without the cap.

author: lollandster
author_rank: Contributor
timestamp: June 16, 2019, 10:59:05 am
content: Quote from: HB9EVI on June 16, 2019, 10:38:05 amNow that you mention it, the AN4080 does show a 100nF cap on the reset switch. I just ordered the board so it will have to survive without one.I did find a rather big error when laying out the board though. VDDA was connected directly to ground. I fixed that.