Author Topic: CH32V003 warning - Don't leave SWIO/PD1 floating!  (Read 1032 times)

0 Members and 1 Guest are viewing this topic.

Offline mikeselectricstuffTopic starter

  • Super Contributor
  • ***
  • Posts: 13761
  • Country: gb
    • Mike's Electric Stuff
CH32V003 warning - Don't leave SWIO/PD1 floating!
« on: April 05, 2024, 05:12:37 pm »
Just did a small production batch (300) and had about 5 units randomly resetting after a few secs to a few mins.
Turns out the cause was leaving SWDIO/PD1 floating.
Fix is to either add a pullup/pulldown R, or set bit 26 of AFIO->PCFR1 to make the pin I/O, and enable pullup/pulldown I/O mode on PD1.
Latter may disable debug functionality but it seems to still allow reprogramming without access to the reset pin.

Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 
The following users thanked this post: Ed.Kloonk, OZ1LQB, rhodges

Offline rhodges

  • Frequent Contributor
  • **
  • Posts: 306
  • Country: us
  • Available for embedded projects.
    • My public libraries, code samples, and projects for STM8.
Re: CH32V003 warning - Don't leave SWIO/PD1 floating!
« Reply #1 on: April 05, 2024, 05:47:09 pm »
It sounds like a temporary workaround would be a jumper on the 3-pin programming header.
Currently developing STM8 and STM32. Past includes 6809, Z80, 8086, PIC, MIPS, PNX1302, and some 8748 and 6805. Check out my public code on github. https://github.com/unfrozen
 

Online HwAoRrDk

  • Super Contributor
  • ***
  • Posts: 1492
  • Country: gb
Re: CH32V003 warning - Don't leave SWIO/PD1 floating!
« Reply #2 on: April 05, 2024, 08:33:48 pm »
That's weird. I haven't encountered such a problem myself. Not even with devices running continuously for many hours on end. I've never put any external pull-up/down on the SWDIO, and in my code although I am always configuring that pin explicitly as an input, it is without internal pull-up/down.

Maybe configuring PD1 as input is all that is necessary, regardless of internal pull-up/down setting. The datasheet is ambiguous as to whether SWDIO is active or not by default on that pin at reset. In section 1.4.16 it says: "The default debug interface pin function is turned on after system power on or reset", but then the pin-out table states that "Main function (after reset)" for PD1 is "PD1" (i.e. GPIO). I suspect it's the former.

Are you absolutely sure it wasn't a problem with NRST/PD7? I have had problems with the reset pin being overly sensitive and causing random resets, fixed by adding a 100nF capacitor there.
 

Offline mikeselectricstuffTopic starter

  • Super Contributor
  • ***
  • Posts: 13761
  • Country: gb
    • Mike's Electric Stuff
Re: CH32V003 warning - Don't leave SWIO/PD1 floating!
« Reply #3 on: April 05, 2024, 09:42:59 pm »
Yes, certain - PD7 has an internal pullup, but PD1 floats, which is never a good thing, even on pins that aren't connected to debug circuitry.
Had 3 units that reliably would reset after 10-20 seconds running. Grounding PD1 fixed them reliably.

Enabling pullup/down didn't actually enable pullup/down until I set bit 26 of the AFIO->PCFR1 register.

The SPI port was routed to a header alongside PD1, and it always reset at some random time within a SPI access, so I suspect it was noise coupling.
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 
The following users thanked this post: rhodges

Online DavidAlfa

  • Super Contributor
  • ***
  • Posts: 5932
  • Country: es
Re: CH32V003 warning - Don't leave SWIO/PD1 floating!
« Reply #4 on: April 05, 2024, 11:58:09 pm »
Ubused pins should he configured as analog to turn all its circuitry off.
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf