2021-04-14 09:12 PM
Since there was no "RST" or "NRST" pin on this chip.
2021-04-14 10:22 PM
On page 12 of the datasheet it says this:
As the NRST pin is not available on this device, if the SWIM pin should be used with the I/O pin functionality, it is recommended to add a ~5 seconds delay in the firmware before changing the functionality on the pin with SWIM functions. This action allows the user to set the device into SWIM mode after the device power on and to be able to reprogram the device. If the pin with SWIM functionality is set to I/O mode immediately after the device reset, the device is unable to connect through the SWIM interface and it gets locked forever. This initial delay can be removed in the final (locked) code.
If the initial delay is not acceptable for the application there is the option that the firmware reenables the SWIM pin functionality under specific conditions such as during firmware startup or during application run. Once that this procedure is done, the SWIM interface can be used for device debug/programming.
I think it means that the device is in SWIM mode for 5 seconds after powerup when it leaves the factory. And that you have to make sure you have such a delay in your code as well. Otherwise it wouldn't be possible to program it at all.
Weird chip.
2021-04-15 05:01 AM
I read this just now, as I understood, if I used pin 8 as PD5, no setting is needed since PD5 is the default configuration of pin 8.
If I want to use pin 8 as SWIM, then I need to set this in Option Word.
If I want to reused pin 8 as PD5 or PD3/PD1/PC6 after I have configured it as SWIM , I need to delay 5 seconds before altering.
Is that right?
2021-04-15 05:20 AM
While, I found no item for SWIM in "OPTION BYTE" of STVP, how to configure it? Is "SWIM" would be the default configuration if I haven't used PD5/PD3/PD1/PC6, since it already shown in the bottom-right corner - "SWIM"?
2021-04-15 05:20 AM
The way I read it is that the first 5 seconds after poweron, the pin is configured as SWIM. After those 5 seconds it switches to what you have set it to in the Option Word.
AND!!! that you have to do the same in your code. Leave it in SWIM mode for the first 5 seconds, else you lose access to debug/program it.
So do NOT remove this initial delay. At least not, until you are sure the code is fine and you'll never have to change it.
2021-04-15 05:23 AM
Can you find something about the delay they talk about? I do not have this chip (and I'm not going to buy this weirdo) so I cannot check anything. I'm afraid it comes down to RTFM :)
2021-04-15 11:47 AM
Hi! I don't really understand what you guys talk about. Programming this chip is easy and straight forward, if you understand what you are doing.
First thing to understand is that on these 8-pin devices, the multiple ports you have on one pin are internally tied together.
Second thing, if you don't have a reset pin, than in order to program the device you need the SWIM pin functional. This means, all ports tied to it: PD1 (actual SWIM), PD3, PD5, PC6; need to be inputs and not driven externally.
The 5 s delay in the manuals is just a possible solution for programming, to wait before you can configure any of these ports as outputs, and before you disable SWIM from within the application. But you can also use different solutions, like checking another pin's status at startup, to know if you start the application code or wait for programming - this depends on your setup, and what you have available to signal this.
The startup delay is healthy to use until you have a functional code, not to lose the device by some mistake.
2021-04-15 12:06 PM
Ah, so the default is that SWIM is active, and if you want to use that pin for something else to simply change it later. It does mean that if you forget to put in a check for some condition or a delay before changing it, you could lose access to the mcu, that would probably happen to me. I'll stick to mcus with a NRST pin.
2021-04-15 05:04 PM
2021-04-16 12:10 AM