Using a USB cable for SWD interface

I've seen a few posts about this, but they are all old, and maybe don't apply to USB-C

We have a device that already uses USB-C for battery charging. We want to carry the SWDIO and CLK signals using the USB-C cable. We don't expect to be able to just plug this into a computer to flash. We will of course have a custom interface to connect this properly to the JLink or other programmer.

The question is, is it safe to do this? We don't want damage to either the computer or the nRF52832 if the user connects this to the computer. It would be common for users to charge the device with a computer, so 100% this will happen often. 

Anyone got recommendations on which pins to use? Anyone done and tested this?

  • Hi,

    The question is, is it safe to do this? We don't want damage to either the computer or the nRF52832 if the user connects this to the computer. It would be common for users to charge the device with a computer, so 100% this will happen often. 

    As long as the signals connected to the SWD port doesn't exceed the absolute maximum ratings then it should be safe,

    Whether it will work is a different question, and tbh you just have to build a prototype and test. I can't tell you for sure, I've seen designs where people have routed the SWD lines through USB and it resulted in it not working because of the long trace, or it worked but only on the lowest possible programming frequency also due to the long trace.

    regards

    Jared 

  • I don't think the wire length will be an issue. We will have a custom interface board to plug into the JLink. Just have a short cable for that. And you are correct, just need to test this. Probably some protection on the pins would also be a good idea.

  • Looking at this further. We use USB-C on our device. So that means its got the CC1 and CC2 pins available on 6 pin plug we planned to use. I don't think that would be a good idea. So will have to use 12 pin receptacle instead.

    Also trying to figure out if its possible to use some of the other pins for board diagnostics, such as power supply voltages, etc.

    Best way is some type of "switch" to turn all off. Just turn them on with some signal, maybe even BLE command.

  • Sounds good! 

    What kind of protection were you thinking of on the SWD pins?

    regards

    Jared

  • Reading the documentation, it says there is already TVS on all the GPIO, so maybe not necessary at all. I did a quick test. Using a USB-C type cable, so I'm connected to the CC1 and CC2 pins. I connect it to the computer, and get the "unknown USB device" error. But my device continues to function no problem. No damage to the SWDIO or SWCLK pins. Tested can flash properly.

    I don't really understand the USB C spec that well. But I see one possible problem. I think it uses those pins to set the correct VBUS voltage, so maybe could accidentally apply more than 5V to the charging circuit. I guess a zener can take care of that.

Related