Forum : ST7/STM8
Original Post
Post Information | Post |
---|---|
March 27, 2012 - 12:17am
|
Hello, I am trying to write the far code space on an STM8L151C8 (address 0x10000 and up). To do this, I have a flash program block routine that executes out of RAM, which programs a single 128 byte flash block at a time. The problem is that in order to write to far addresses, I have to use far pointers and 32-bit variables, which results in |
Hi,
Your post looks unfinished, but I got the idea: The far code access is very poor on the STM8. This is because there are not enough registers to hold both 24-bit source and destination addresses when performing object-to-object copies.
Here is an hidden treasure, an assembly subroutine that will help you a lot:
Add this in a .asm file in your application, then you can call it as follows:
Using this you will have to copy this function to a specific address in RAM (refer to the RCSTM8 compiler documentation that describes this), then write your inram function that uses this as a helper for efficient copy of bytes to destination RAM.
Best Regards,
Hi Bruno,
Thanks for the response. The forum apparently chopped off half of my post, but I ended up figuring out how to resolve my issue through other posts on this forum.
I basically wrote a flash block program routine that assumes the hi 16-bits of the address stays constant, and the low 16-bits gets incremented to write all 128 bytes of the block. I could do this without invoking any 32-bit variable "helper" functions, and therefore not violating the "must not access flash while programming flash" rule.
Your code looks incredibly useful though. I may have another use for it.
Thank you!
Great job bcoons!