We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I have a Cypress 8051 system which has 6K internal RAM and a 64K Flash ROM external to the uP. The internal RAM can be used for data and/or code. What I'm trying to do is move a few "flash updating" routines into the RAM and execute them from RAM. They would operate on the external flash ROM. My issue is that I don't know how to have these routines link to the area where the will eventually run. I've read app note 138 (for the 166 family and there are so many differences I don't know why people at Keil tell me to refer to that app note) I've done flash programming in other systems, so I'm aware of the issues. I need to know how to control the Keil compiler so my code ends up in the proper places. For example, there some BL51 locate parameters like "Code Range" and "Xdata Range" I've been setting the code range to "0x2000-0xffff" because that is (basically) the range where the external flash rom is decoded. The lower area is for the internal RAM resource. However, I want to run a function write_flash_block() from 0x400 (down in RAM). How do I tell it the runtime location is 400, but it's stored somewhere (anywhere actually) in Flash???
Because the 8051 is a Harvard architecture device, you cannot execute from RAM... without hardware assistance that is. You will need to be able to map the /PSEN line over to your RAM's /OE or /CE once you have copied the code into the XDATA space. - Mark
On the Cypress "EZUSB" 8051 devices, you can run code from the internal RAM. It's mapped as code and data space. I'm trying to link code as if it exists there, but is stored somewhere else in flash memory. I want to then "copy" the functions to the lower RAM and run 'em from there.
Welcome to the world of relocation. You must either teach the linker to fixup the run-time addresses to match the RAM addresses or you must copy the functions to RAM and then create function pointers to them at their RAM addresses. Then call the functions via the function pointers. - Mark
Be sure to read-up on all the Gotchas! with function pointers in C51: http://www.keil.com/support/docs/210.htm Application Note 129
Thanks for the reply! It's funny that Keil supports this easily on the 166 tools, but the more mature 8051 tools do not have it! I'm just trying to figure out the most maintainable method to do this. Thanks, Tony