cancel
Showing results for 
Search instead for 
Did you mean: 

Can't connect to STM8L052C6

CDarw.1
Associate II

Hi,

I'm attempting to connect to STM8L052C6 with ST-link and receiving an error, "Cannot communicate with the device !"

I've read every forum post on google related to the issue and tried just about everything to connect.

Finally I found in the manual for SWIM entry sequence in reference to activation timing to make SWIM active the pin must be forced low during 16µs, next a sequence of four pulses at 1kHz (1ms), followed by four pulses at 2 kHz (500µs)

When I checked the pulses I found the initial low is 1.317ms, followed by four pulses of 1.334 ms, then four pulses of 0.667 ms

Could this timing be the issue why SWIM is not initiating?

0693W000005AX9pQAG.png0693W000005AX9zQAG.png

1 ACCEPTED SOLUTION

Accepted Solutions
CDarw.1
Associate II

Thanks for your responses Peter.

I resolved the issue by buying a new genuine ST-Link V2 and it worked like a dream. Something's wrong with my old one.

Figured I'd post the solution in case someone else has the same issues and stumbles on this. I was going crazy trying to connect to the board, literally trying everything thinking I was doing something wrong.. browsing every forum including the Russian ones - and I don't speak Russian!

View solution in original post

7 REPLIES 7
Peter BENSCH
ST Employee

This timing of the entry sequence is the correct one. You will find the description in UM0470, section 3.2, which says e.g.:

The SWIM entry sequence is: four pulses at 1 kHz followed by four pulses at 2 kHz. The frequency ratio is detected and allows the SWIM entry. The ratio can be easily detected regardless of the internal LSI frequency value.

You've measured 1.334ms/0.667ms, which matches perfectly the given ration 2:1.

But what about the expected response where the HSI should have been turned on (right part of the diagram of fig 4)?

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
CDarw.1
Associate II

Hi Peter, thanks for the response. The pin goes drops quickly four times, and this happens with or without the chip connected.

0693W000005AfVZQA0.png

Peter BENSCH
ST Employee

It looks like the STM8 isn't responding with the correct pattern. Do you also use pin 1 for other functions on your board?

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
CDarw.1
Associate II

The STM8 is not responding at all, that pattern happens regardless of the chip connected or not.

pin 1 is not connected to anything else, only the programmer. NRST connected to the programmer with a capacitor to ground

It's my understanding that when achieving a reset condition the program is not run, so SWIM cannot be disabled.

One thing I've noticed after launching STVP I can attempt to read the chip 1 time, then Reset is held low until either the STLink v2 USB is disconnected/reconnected OR exiting STVP and relaunching. Is this normal behavior?

Peter BENSCH
ST Employee

Besides debugging: does the application still work normally with the STM8?

You are right, SWIM will be usable when reset (and power supply) is activated, so it looks like a faulty STM8. Do you have the chance to test it with other systems too?

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
CDarw.1
Associate II

Thanks for your responses Peter.

I resolved the issue by buying a new genuine ST-Link V2 and it worked like a dream. Something's wrong with my old one.

Figured I'd post the solution in case someone else has the same issues and stumbles on this. I was going crazy trying to connect to the board, literally trying everything thinking I was doing something wrong.. browsing every forum including the Russian ones - and I don't speak Russian!

Peter BENSCH
ST Employee

Thank you for updating the thread!

When your question is answered, please close this topic by choosing Select as Best.

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.