2021-09-28 01:07 AM
Hello,
I try to read from user flash. Everything is fine until I try to read from address beyond 0x10000. Then I get random values. I use SDCC (3.8.0 and 4.1.0, the behaviour is the same). My device is STM8AF5288 which has 64 KB of flash memory. A program which is located at the flash and occupies it beyond address 0x10000 runs fine (compiled with memory model large), but reading the flash using the StandardPeripheralLibrary function FLASH_ReadByte() returns random values.
A similar question is already here:
using IAR compiler and other STM8 device, but it was closed without solution.
If I look at generated asm code, I see:
ldw x, (0x08, sp)
ld a, (x)
ld (0x01, sp), a
generated for it. I would have expected ldf instruction instead of ldw instruction here, but I am not sure.