Reputation: 1
I'm trying to work make SWIM activation sequence for STM8 by external microcontroller of another company.
I use timing diagram from UM0470
In phase 4 STM8 should respond to host by keeping swim pin LOW for 128 HSI cycles having frequency about 8MHz (about 16 microseconds overall). But STM8 does not respond.
I checked timings by oscilloscope and in phase 1 duration of low level keeping is 16 us, pulses in phase 2 are 500 us and 250 us (semiperiods of 1 KHz and 2 KHz respectively). For final negative impulse I've tried 500us and 250 us and it did not matter. For phase 3 I tried durations of 350 ns, 800 ns and 1 us (according to UM0470 it must be at least 300 ns). Voltage levels correspond to that is written in STM8 Datasheet.
What may be the cause of this problem and how to resolve it?
Upvotes: 0
Views: 139
Reputation: 302
Swim uses a single wire with pull up. much like i2c this means you must reconfigure your IO to be HI-Z when not sending a low signal or otherwise guarantee that the line is free when not in use. I use a discrete circuit like this:
RX and TX are connected to the host. SWIM is connected to the stm8. The advantage of the discrete interface is that it allows you to separate RX and TX which makes development easier. Galvanic isolation of the SWIM interface also becomes trivial (I needed that for my application).
I think I used 47kOhm for the pull up resistor. It shouldn't matter too much what it is as long as it is small enough to keep rise time from being too slow.
The SWIM start procedure I use looks like this:
Note the initial 16us pulse. This seems to be required to initially wake up the swim interface.
Note the MCU RESPONSE. This is the pulse labelled (4) or synchronization frame in the ST documentation. Whoever made that diagram did not care scale the pulses even remotely proportionally...
Note that if swim is already active, it will interpret parts of the start sequence as communication reset requests and you will see synchronization frames after each pulse in the start sequence.
A closer look at the response from the stm8:
As documented it is a 16us pulse you can use to verify the stm8's internal rc oscillator or just ignore.
After activating the swim interface you can send one of the three supported commands. Bellow is a ROTF read on the fly request (the answer is not depicted)
Note that the start and parity bits are in blue.
Note the acknowledge bits received after each part of the request.
Note how tight the timing in the signal is. I used an fpga to produce this trace. It is not necessary to have such tight timings. You can leave ample time between the bits and bytes of the communication.
After receiving the ROTF command the stm8 will read and push out each byte, waiting for an acknowledge after each byte.
Upvotes: 0
Reputation: 1
I am doing something similar now, but with an incircuit tester.
Some things to try:
I will update this post if / when I am successful at connecting to an STM8 chip.
Upvotes: 0