2020-04-01 05:17 AM
Hello Everyone,
I am to test a device which uses the STM8S207RB as the controller. The controller's pin 25 and 26 are used for I2C communication. But in order to use it for the SDA and SCL signals, I need to remap its function by changing the AFR6 bit of the AFR register(OPT1) to 1 (and also the complementary register NOPT1 to 0). I went through many documentations and finally found document UM0560 which gives instruction on how to program the memory via the embedded Bootloader (note that I only have access to the controller via the UART interface).
I followed the instruction provided and changed the AFR6 (AFR to 0x40 for OPT1 and 0xBF to NOPT1) using the following command:
0x31 CE 00 00 48 03 4B 01 40 BF FE (where 00 00 48 03 is the AFR address, 40 is the value to write, 31 CE is the write command)
After that I issue the read command (11 EE 00 00 48 03 4B 02 FD) to verify that the AFR is indeed changed.
I reset the device and noticed that the microcontroller does not react anymore. I could not communicate with the microcontroller and could not trigger it into the bootloader mode again.
Does anybody has this experience? Is there anything happening in the background while changing the AFR6 bit that locked up the microcontroller?
yours sincerely,
hlim
2020-06-11 02:39 PM
If the MCU is not responding via UART, have you tried using SWIM? I do most of my programming using a STlinkv2 usb adapter and stm8flash under linux. There was an instance when I attempted to enable the bootloader by writing 55AA to OPTBL but contrary to expectations, the MCU did not enter bootloader mode when reset and the SYNCHR (0x7F) character sent to it. By reading the option bytes starting at 0x4800 (using stlinkv2/SWIM) I noticed that all the bytes were zero (instead of being 00 00 FF 00 FF ... [factory default]). After changing these to factory default, the bootloader started responding again ...
My point is, check what you have starting at 0x4800 and if the values are not what you expected, change them to default values and try again.