# ST-Link V2 Programming STG-850 PLC — STM32

I'm trying to connect to a Barth STG-850 PLC for the first time and am using the ST-Link V2 programmer (not the ISOL version) and have been unsuccessful so far.

The crux of my problem likely stems from not having the recommended cable for connecting from the JTAG connector to the PLC, which is the VK-35 cable also sold by Barth. I ordered the cable but won't have it for 1-2 weeks, so I have been trying to connect without it.

I've powered the PLC externally with 12V. Connected the ST-Link to my PC and installed both STM32 ST-Link Utility and Keil MicroVision to try to establish connection with the PLC. For connections between the PLC and the JTAG connector I've connected the following:

After trying several options I seem to be stuck at two errors, either "Can not connect to the target" or "STLink USB communication error" although the USB comm error I can get to go away just by unplugging and re-plugging in the ST-Link. Both can be seen in this pic:

This is rather specific, but does the VK-35 cable do anything besides just connecting the corresponding pins?

One function I thought the cable might be doing would be to invert the reset pin (pin 5 on the PLC) since there is a "(inverted)" in the data sheet for the reset pin.

I've started focusing more on the reset pin since I've learned that to flash the software the reset pin is usually toggled in a sequence or held to a specific state. Also if I just plug the reset pin in how I've shown it wired above then the normally blinking status LED on the PLC goes out. Since I noticed the "(inverted)" comment I tried inverting the signal by passing it through an arduino and simply flipping the signal. That gets the PLC LED to stay blinking while the programmer is in but I still get the above errors.

I'm hoping that some of you with more specific knowledge on ISP's and/or STM32 MCU's will have better intuition on my problem.

VK-35 Programming cable: https://barth-elektronik.com/en/connection-cable-vk-35.html

Thanks!

Below is the error log I get from the ST-Link Utility when I try to connect with the reset pin (pin 5 on the X4 connector) plugged into the ST-Link programmer. Changing the mode to "connect under reset" gives the same result.

USB communication error (65657) after target cmd F1 80 00 00 00 00 00 00 00 00
The detected STM32 firmware version (V0.J0) does not support the DAP read command.


When I try connecting without the reset pin plugged in I get the following error log from the ST-Link Utility:

ST-Link/V2 device detected
Target voltage detected: 0.000000
No target device detected: check JTAG signals
Error (4) while initializing ST-Link in JTAG mode


The "Target voltage detected: 0.000" makes me think I might have something mis-wired on the ST-Link JTAG side. The PLC has 3.3V and Gnd properly connected.

• Did you have any success? X4 connector should straight away work with STlink.. Remember to power the board externally. – Umar Jun 10 '18 at 9:23
• @Umar no success yet. I've powered the board externally. I'll pull apart my setup and re-try in case there's a mistake somewhere. Do you know if there's a typical high/low sequence or state for the reset pin on a STM32 to initiate programming? – flanman1866 Jun 10 '18 at 15:44
• Not really. One option you can try is selecting "connect under reset" option in ST Link – Umar Jun 10 '18 at 15:51
• You can check once whether 3.3v is available or not at pin number one of X4.. Cross check the cable connections.. You are using SWDIO and SWCLK..you can try without Reset pin connection too.. I do it. – Umar Jun 10 '18 at 15:54
• Thanks for the advice @Umar I tried the connect under reset option you suggested and added the error log from ST Link Utility to the post info above. I also tried removing the reset pin wire and posted that error as well, which is a little more interesting since it seems to say it doesn't detect any voltage on the target device. I checked the voltage levels on the PLC X4 connector, and gnd is on pin 2, and 3.3v on pin 1. To the JTAG connector I have everything wired to match the "SWD" column from the documentation. – flanman1866 Jun 10 '18 at 19:10