AnsweredAssumed Answered

STM32F042F6Tx SWD problem [solved: this is how swapping SWCLK and SWDIO looks like]

Question asked by Valentin on Nov 7, 2016
Latest reply on Nov 7, 2016 by Nesrine M
I too seem to be unable to talk to my F042. I just finished some new boards with a new design.

I'm using NRST, SWDIO and SWCLK to connect from the SWD header of a discovery board to the F042. I triple checked and confirmed that SWCLK is on pin 20 (PA14) and SWDIO on pin 19 (PA13). NRST is pulled high, even though the NRST state doesn't really matter for SWD connection. I tested that using another board. Works fine with NRST low or high.

This is what ST-Link says about the problem:
01.cErrLog::SetLogTraceOn
02.STLinkUSBDriver.dll loaded
03.ST-Link/V2 device detected
04.Target voltage detected: 2.893326
05.Error (0x16) after target cmd F2 30 A3 00 00 00 00 00 00 00
06.Error (19) while initializing ST-Link in SWD mode
07.ST-Link/V2 device detected
08.Target voltage detected: 2.896161
09.Error getting target IDCODE: if SWD, check SWD connection
10.Error (4) while initializing ST-Link in SWD mode
11.ST-Link/V2 device detected
12.Target voltage detected: 2.893326
13.Error getting target IDCODE: if SWD, check SWD connection
14.Error (4) while initializing ST-Link in SWD mode
15.ST-Link/V2 device detected
16.Target voltage detected: 2.894743
17.Error getting target IDCODE: if SWD, check SWD connection
18.Error (4) while initializing ST-Link in SWD mode
19.Error (0x16) after target cmd F2 3E 00 00 00 00 00 00 00 00
20.Error (19) in ReadMemory_32Bit (4 bytes from 0x40015800)
21.Error (0x12) after target cmd F2 36 04 58 01 40 00 00 00 00
22.W at 0x40015804: 0x00000000
23.Error (0x12) after target cmd F2 35 04 58 01 40 00 00 00 00
24.W at 0xe000edf0: 0xa05f0000
25.Error (0x12) after target cmd F2 35 F0 ED 00 E0 00 00 5F A0

And this is what it looks like when debugging the lines directly:
[url=https://postimg.org/image/acq3k3qw9/][img]https://s12.postimg.org/acq3k3qw9/screenshot.png[/img][/url]
[url=https://postimg.org/image/t6bwh3p49/][img]https://s12.postimg.org/t6bwh3p49/screenshot2.png[/img][/url]

Looking at the analog version of SWDIO, it seems as if the F042 pin is somewhat struggling to drive the line properly during the IDCODE request?
It's also weird that there are transitions happening in between bits.

This is a snapshot of the PCB layout with the SWD tracks highlighted:
[url=https://postimg.org/image/m6ud5k00z/][img]https://s21.postimg.org/m6ud5k00z/pcb.png[/img][/url]

Those pins go directly to the SWD header on the discovery board using a 10 pin ribbon.
Any idea anyone?

Thanks!

(btw: the forum is painstakingly slow and why doesn't it read html or bbcode?)

Edit: never mind. SWDIo and SWCLK were swapped ...... I'll leave this here for everyone else to learn from :)

Outcomes