2009-09-24 03:48 AM
Hardware failure with SD interface
2011-05-17 04:24 AM
Is there an ''official'' schematic on how to connect a SD(HC) card to stm32 microcontrollers?
By official I mean one which is approved by ST or is known to comply with absolute-maximum ratings for the stm32. I have made five identical prototype boards which use stm32f103CB to log data to a SDHC card. I based the interface on the Olimex STM32F103-STK . That has SPI2_NSS, SPI2_MOSI, SPI2_SCK directly and only connected to their appropriate pins on the SD-card connector; SPI2_MISO directly connected but with 10k pull-up, and a 470 nH inductor between main Vdd and the power pin on the SD-card connector with 47uF on the card-side of the inductor to Vss. I made the following changes: - Supply-voltage = 3.0V (not 3.3) - Power to the SD-card can be switched off by a power PMOS switch (with the Olimex L-C filter after the switch; before turning this off I change the control lines to input-with-pull-down) - Much shorter pcb tracks (4-layer board with ground-plane; tracks between cpu and sd-card all less than 30 mm long). - Use of 48-pin microcontroller rather than 64-pin to save pcb space The processor has 100nF multilayer ceramic decoupling capacitors at every power-supply pin, as well as a nearby 22uF tantalum capacitor. My software is based on DOSFS with a some low-level tweaks to allow multiple threads to access the SD-card using the Crossworks Tasking library. The processor runs at 72 MHz (from an 8 MHz external crystal) and the SPI interface clocks at 18 MHz (SPI2_CR1.BR = 0b000 i.e. fPclk/2 with APB1 at 36 MHz from RCC_CFGR.PPRE1 = 0b100 i.i. HClk/2) and the SPI output pins are programmed to be Alternate-function push-pull at 50 MHz. Two of those boards have now failed in the same way, both after writing and reading back around 100 MByte of data. The symptoms of the failure are that there seems to be a low resistance between SPI2_SCK (=CLK/SCLK) and Vss. On one board this resistance is 10 ohms and on the other board it is nearer 4 ohms. These failures were with different uSDHC memory cards. This is a ''hard'' fault - resetting or power-cycling the boards does not fix the fault, and it is still there with the microSDHC card removed. Has anyone else seen this failure mode - on SPI or any other I/O? Does anyone have any suggestions as to what I might be doing wrong? Is 18 MHz too high for stm32 to talk to SDHC over SPI? (The SD card specification says 0 - 25 MHz can be used). If so, and I go to 9 MHz, should I switch the I/O pins to 10 MHz rather than 50 MHz? I have seen 100-ohm series resistors between microcontroller outputs and the SD-card connector, but that was on a Keil demo board for an NXP LPC2148 microcontroller. Does anyone use such resistors with STM32 microcontrollers? Does anyone think this value (or larger) will help? This is not practical on the current board but if it is thought to be a fix then I can prepare a new pcb layout. If I have missed off any information which will help diagnose the problem, please let me know and I can post it.2011-05-17 04:24 AM
It sounds like it might be destructive latch up possibly caused by ESD. Did the fault appear while the card was fitted and not touched or did the fault appear after removing and re-inserting the card. Have you any ESD protection on the SD card lines? I would definitely fit the 100R series resistors in series with the signal lines and put esd protection on the card pins to protect the STM32.
Trevor2011-05-17 04:24 AM
Hi Trevor,
Thanks for your reply. The SD cards have been permanently left in, so ESD is unlikely. (The contacts in the connector are staggered, which I think is to ensure that power lines mate first and reduce the risk of ESD). Does 100 Ohms sound like a good value to you? For ESD protection - just a discrete diode clamp to Vdd and Vss (I have pairs of Schottky diodes in SOT223)? I will need to check junction capacitance but 18 MHz isn't _that_ fast. I have checked some other Keil demo boards - I see the 100 ohms on NXP boards but not on ST boards. - Danish2011-05-17 04:24 AM
To some extent answering my own question, I have come across a ''reference'' design at
http://www.st.com/stonline/products/support/micro/files/stm3210c-eval.zip
dated June 2009 This does not seem to have any protective components between the microcontroller and the SD-card on SCK or MOSI. (There are a 0-ohm resistors in series with MISO, CS and card-detection, but they could be to allow the pins to be used independently from the SD-card). So I am still left wondering what I am doing wrong on my circuit boards that seems to make output pins burn out, and a reliable way to prevent it. Oh and do mention ''obvious'' or ''beginners'' mistakes. Don't think I am too smart to fall into beginners traps because I rattled off a list of the things I _had_ thought about. There's no so blind as them that don't see. Regards, Danish2011-05-17 04:24 AM
This may be irrelevant, but I have previously ''blown up'' ICs by creating transient high voltage spikes from power switch on. The inductance of quite short (500mm) leads can be enough if the power is switched suddenly.
You mentioned a power PMOS switch and Olimex L-C filter. Are these causing a voltage spike? The SD card itself is designed to be ''hot-swappable'' so do you even need to power down the socket? The STM3210E-EVAL Evaluation Board just connects the card / socket to +3.3V. PS Thanks for your advice about embedded assembler.2011-05-17 04:24 AM
Egg on face time.
Having fitted new stm32 microcontrollers onto the failed boards, the problem returned within minutes. So I took the microcontrollers off. It turns out that the short-circuit is an intermittent fault on both bad PCBs (but not on the other 8 PCBs made in the same batch). Looking through the boards on a light box, I see that the inner ground-plane layer is significantly misaligned - probably by about 0.20 mm - and this is enough for a via to short to the ground plane! Sorry to waste everyone's time. - Danish