locate a function in RAM

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

locate a function in RAM

1,106 Views
juliancox
Contributor V

I am still battling to implement a Write a byte in EEPROM. I know that the erase/program functions must be executed from RAM and several posts discuss moving a function into RAM. My question is - Can I specify a RAM address for the necessary functions so that they reside in RAM at build time and I don't have to move them - I can just call them in the normal way (assuming I first disable interrupts). Surely this would speed up overall execution time and reduce code size. If this is possible, how do I do it?

Tags (2)
0 Kudos
8 Replies

827 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello julian,

I just want to know which product and which version of CW you used , if kinetis , please refer to this thread to relocate function to RAM:

https://community.nxp.com/docs/DOC-101433 

Hope it helps

Alice

0 Kudos

827 Views
juliancox
Contributor V

I am using CW 10.7 and S08SH4 processor

0 Kudos

827 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Julian

Yes, You can do it, please refer attached demo code. It was made under CW6.3 but it is easy to be imported to CW10.7.

Please refer S08_Flash.c, S08_Flash.h, main.c


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

827 Views
juliancox
Contributor V

Hi Jennie,

You forgot to attach the attachment!!!!

0 Kudos

827 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Julian,

I did attached it. see:

pastedImage_2.png

Can't you see it? if not, please send me your email, I can send it to you. I just followed you. you can add me then send your email address with message.

Have a great day,
Jennie Zhang

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

827 Views
juliancox
Contributor V

It eventually appeared. I think it was something to do with my browser (Safari)

Thanks.

0 Kudos

827 Views
juliancox
Contributor V

Hi Jennie,

Thanks for the help. I modified your project to remove the burst programming option (not needed) and changed the .prm file as I am using a SH4 chip, not a SH8. Everything worked fine so I copied the CopyTo Ram(), FlashInit() and FlashCmd() functions into my project. FlashInit() and CopyToRam() work fine, but it fails on Erase - does not return as expected. I think that something is getting corrupted in RAM, but at this stage I don't know whether it is the stack, the relocated FlashCmd() function or the variables. More work is needed. Two questions -

1. Do I need to disable interrupts during erase and program?

2. Can I debug the FlashCmd with the USBDM?

Regards

Julian

0 Kudos

827 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

hi Julian,

Regarding to your questions

>>1. Do I need to disable interrupts during erase and program?

Yes, you do. Because erase/program can't be successfully if they are interrupted during the time.

>>2. Can I debug the FlashCmd with the USBDM?

yes. but please note we can't step over the FlashCmd code, it will destroy the erase/program time sequence.


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos