By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,062 Members | 2,370 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,062 IT Pros & Developers. It's quick & easy.

Trying to run a function in RAM and not in Flash using function pointer

P: n/a
I have written a C function to copy a flash write routine that is in
Flash memory to RAM memory. I have then created a function that
uses a Function Pointer to run the copied function in RAM.

My problem is that I have not successfully been able to run the
function out of
RAM.

Here is my function

void write_data_params(void)
{

int (* p) (unsigned short *src_addr, unsigned long dst_addr, int
write_size); // p is a pointer to a function

short_int_array[0] = 0x2211;
short_int_array[1] = 0x4433;
short_int_array[2] = 0x6655;
short_int_array[3] = 0x8877;
short_int_array[4] = 0xaa99;
short_int_array[5] = 0xbbaa;
short_int_array[6] = 0xddcc;
short_int_array[7] = 0xffee;
short_int_array[8] = 0x2221;
short_int_array[9] = 0x2423;
short_int_array[10] = 0x2625;
short_int_array[11] = 0x2827;
short_int_array[12] = 0x2a29;
short_int_array[13] = 0x2c2b;
short_int_array[14] = 0x2e2d;
short_int_array[15] = 0x302f;
short_int_array[16] = 0x3231;
short_int_array[17] = 0x3433;
short_int_array[18] = 0x3635;
short_int_array[19] = 0x3837;
ret_value_flash_data_write = fmWriteFunctoRam(); // write function
to RAM
// p = (UHWORD *) fmDataWriteG; // when using this statement
running function inflash
p = (int (*) (unsigned short *, unsigned long, int )) 0x10005000;
sprintf(str, " p %x *p %x \r\n", p, ( UHWORD*)p); // p
10005000 *p 10005000
uprintLine(str);
ret_value_flash_data_write = p(short_int_array, 0x30000, 40);

return;
}

Result when I try running this function

p 10005000 *p 10005000
Soft reset occurred
peekw 0x10005000 10

peekw 0x10005000 10

Memory dump:
10005000: E1A0C00D E92DD800 E24CB004 E24DD064
10005010: E50B0010 E50B1014 E50B2018 E3A03000
10005020: E50B301C E59F003C EBFFE328 E24B206C
10005030: E51B3010 E1D3C0B0 E51B3018 E58D3000

I tried to see the Value at location p which is the function pointer.
it shows to be 10005000 and the Address shows to be the same value
10005000.

when I do a memory dump I can see the data at 10005000 is E1A0C00D.
After the statement

ret_value_flash_data_write = p(short_int_array, 0x30000, 40);

the function should run in RAM. But it gives a invalid instruction
and a Soft Reset occurs.

I tried assigning p to be the Function Address located in the FLASH
MEMORY with the statement
// p = (UHWORD *) fmDataWriteG; // when using this statement running
function inflash

and it did run.

Unfortunately, I need to run the function in RAM and Not FLASH for my
application.

Thank You for your help
Nov 14 '05 #1
Share this Question
Share on Google+
19 Replies


P: n/a
golson <go****@worldnet.att.net> spoke thus:
I have written a C function to copy a flash write routine that is in
Flash memory to RAM memory. I have then created a function that
uses a Function Pointer to run the copied function in RAM. etc.


(The below welcome text was originally written by Ben Pfaff)

Your question is outside the domain of comp.lang.c, which discusses
only the standard C programming language, including the standard C
library. This is a remarkably narrow topic compared to what many
people expect.

For your convenience, the list below contains topics that are not
on-topic for comp.lang.c, and suggests newsgroups for you to explore
if you have questions about these topics. Please do observe proper
netiquette before posting to any of these newsgroups. In particular,
you should read the group's charter and FAQ, if any (FAQs are
available from www.faqs.org and other sources). If those fail to
answer your question then you should browse through at least two weeks
of recent articles to make sure that your question has not already
been answered.

* OS-specific questions, such as how to clear the screen,
access the network, list the files in a directory, or read
"piped" output from a subprocess. These questions should be
directed to OS-specific newsgroups, such as
comp.os.ms-windows.programmer.misc, comp.unix.programmer, or
comp.os.linux.development.apps.

* Compiler-specific questions, such as installation issues and
locations of header files. Ask about these in
compiler-specific newsgroups, such as gnu.gcc.help or
comp.os.ms-windows.programmer.misc. Questions about writing
compilers are appropriate in comp.compilers.

* Processor-specific questions, such as questions about
assembly and machine code. x86 questions are appropriate in
comp.lang.asm.x86, embedded system processor questions may
be appropriate in comp.arch.embedded.

* ABI-specific questions, such as how to interface assembly
code to C. These questions are both processor- and
OS-specific and should typically be asked in OS-specific
newsgroups.

* Algorithms, except questions about C implementations of
algorithms. "How do I implement algorithm X in C?" is not a
question about a C implementation of an algorithm, it is a
request for source code. Newsgroups comp.programming and
comp.theory may be appropriate.

* Making C interoperate with other languages. C has no
facilities for such interoperation. These questions should
be directed to system- or compiler-specific newsgroups. C++
has features for interoperating with C, so consider
comp.lang.c++ for such questions.

* The C standard, as opposed to standard C. Questions about
the C standard are best asked in comp.std.c.

* C++. Please do not post or cross-post questions about C++
to comp.lang.c. Ask C++ questions in C++ newsgroups, such
as comp.lang.c++ or comp.lang.c++.moderated.

* Test posts. Please test in a newsgroup meant for testing,
such as alt.test.

news.groups.questions is a good place to ask about the appropriate
newsgroup for a given topic.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Nov 14 '05 #2

P: n/a
Christopher Benson-Manica writes:
golson <go****@worldnet.att.net> spoke thus:
I have written a C function to copy a flash write routine that is in
Flash memory to RAM memory. I have then created a function that
uses a Function Pointer to run the copied function in RAM.
etc.


(The below welcome text was originally written by Ben Pfaff)


There must be a better phrase than "Welcome message" for a message that says
"Get the hell out of here". This is not in keeping with the avowed intent
of the owners of this newsgroup of being precise.


Your question is outside the domain of comp.lang.c, which discusses
only the standard C programming language, including the standard C
library. This is a remarkably narrow topic compared to what many
people expect.

For your convenience, the list below contains topics that are not
on-topic for comp.lang.c, and suggests newsgroups for you to explore
if you have questions about these topics. Please do observe proper
netiquette before posting to any of these newsgroups. In particular,
you should read the group's charter and FAQ, if any (FAQs are
available from www.faqs.org and other sources). If those fail to
answer your question then you should browse through at least two weeks
of recent articles to make sure that your question has not already
been answered.

* OS-specific questions, such as how to clear the screen,
access the network, list the files in a directory, or read
"piped" output from a subprocess. These questions should be
directed to OS-specific newsgroups, such as
comp.os.ms-windows.programmer.misc, comp.unix.programmer, or
comp.os.linux.development.apps.

* Compiler-specific questions, such as installation issues and
locations of header files. Ask about these in
compiler-specific newsgroups, such as gnu.gcc.help or
comp.os.ms-windows.programmer.misc. Questions about writing
compilers are appropriate in comp.compilers.

* Processor-specific questions, such as questions about
assembly and machine code. x86 questions are appropriate in
comp.lang.asm.x86, embedded system processor questions may
be appropriate in comp.arch.embedded.

* ABI-specific questions, such as how to interface assembly
code to C. These questions are both processor- and
OS-specific and should typically be asked in OS-specific
newsgroups.

* Algorithms, except questions about C implementations of
algorithms. "How do I implement algorithm X in C?" is not a
question about a C implementation of an algorithm, it is a
request for source code. Newsgroups comp.programming and
comp.theory may be appropriate.

* Making C interoperate with other languages. C has no
facilities for such interoperation. These questions should
be directed to system- or compiler-specific newsgroups. C++
has features for interoperating with C, so consider
comp.lang.c++ for such questions.

* The C standard, as opposed to standard C. Questions about
the C standard are best asked in comp.std.c.

* C++. Please do not post or cross-post questions about C++
to comp.lang.c. Ask C++ questions in C++ newsgroups, such
as comp.lang.c++ or comp.lang.c++.moderated.

* Test posts. Please test in a newsgroup meant for testing,
such as alt.test.

news.groups.questions is a good place to ask about the appropriate
newsgroup for a given topic.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.

Nov 14 '05 #3

P: n/a
Your question is outside the domain of comp.lang.c, which discusses
only the standard C programming language, including the standard C
library. This is a remarkably narrow topic compared to what many
people expect.

For your convenience, the list below contains topics that are not
on-topic for comp.lang.c, and suggests newsgroups for you to explore
if you have questions about these topics. Please do observe proper
netiquette before posting to any of these newsgroups. In particular,
you should read the group's charter and FAQ, if any (FAQs are
available from www.faqs.org and other sources). If those fail to
answer your question then you should browse through at least two weeks
of recent articles to make sure that your question has not already
been answered.

* OS-specific questions, such as how to clear the screen,
access the network, list the files in a directory, or read
"piped" output from a subprocess. These questions should be
directed to OS-specific newsgroups, such as
comp.os.ms-windows.programmer.misc, comp.unix.programmer, or
comp.os.linux.development.apps.

* Compiler-specific questions, such as installation issues and
locations of header files. Ask about these in
compiler-specific newsgroups, such as gnu.gcc.help or
comp.os.ms-windows.programmer.misc. Questions about writing
compilers are appropriate in comp.compilers.

* Processor-specific questions, such as questions about
assembly and machine code. x86 questions are appropriate in
comp.lang.asm.x86, embedded system processor questions may
be appropriate in comp.arch.embedded.

* ABI-specific questions, such as how to interface assembly
code to C. These questions are both processor- and
OS-specific and should typically be asked in OS-specific
newsgroups.

* Algorithms, except questions about C implementations of
algorithms. "How do I implement algorithm X in C?" is not a
question about a C implementation of an algorithm, it is a
request for source code. Newsgroups comp.programming and
comp.theory may be appropriate.

* Making C interoperate with other languages. C has no
facilities for such interoperation. These questions should
be directed to system- or compiler-specific newsgroups. C++
has features for interoperating with C, so consider
comp.lang.c++ for such questions.

* The C standard, as opposed to standard C. Questions about
the C standard are best asked in comp.std.c.

* C++. Please do not post or cross-post questions about C++
to comp.lang.c. Ask C++ questions in C++ newsgroups, such
as comp.lang.c++ or comp.lang.c++.moderated.

* Test posts. Please test in a newsgroup meant for testing,
such as alt.test.

news.groups.questions is a good place to ask about the appropriate
newsgroup for a given topic.

--
int main(void){char p[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyz.\
\n",*q="kl BIcNBFr.NKEzjwCIxNJC";int i=sizeof p/2;char *strchr();int putchar(\
);while(*q){i+=strchr(p,*q++)-p;if(i>=(int)sizeof p)i-=sizeof p-1;putchar(p[i]\
);}return 0;}
Nov 14 '05 #4

P: n/a
"osmium" <r1********@comcast.net> writes:
There must be a better phrase than "Welcome message" for a message that says
"Get the hell out of here". This is not in keeping with the avowed intent
of the owners of this newsgroup of being precise.


The intent of the message is *not* to say "get the hell out of
here". It is intended to, as gently as possible, explain why the
OP's article does not fall within clc's topic and guide the OP
to places on the net that better match his question. It is not
perfect, so suggestions for improvement are welcome.
--
int main(void){char p[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyz.\
\n",*q="kl BIcNBFr.NKEzjwCIxNJC";int i=sizeof p/2;char *strchr();int putchar(\
);while(*q){i+=strchr(p,*q++)-p;if(i>=(int)sizeof p)i-=sizeof p-1;putchar(p[i]\
);}return 0;}
Nov 14 '05 #5

P: n/a
Ben Pfaff <bl*@cs.stanford.edu> scribbled the following:
"osmium" <r1********@comcast.net> writes:
There must be a better phrase than "Welcome message" for a message that says
"Get the hell out of here". This is not in keeping with the avowed intent
of the owners of this newsgroup of being precise.
The intent of the message is *not* to say "get the hell out of
here". It is intended to, as gently as possible, explain why the
OP's article does not fall within clc's topic and guide the OP
to places on the net that better match his question. It is not
perfect, so suggestions for improvement are welcome.


You are right that its intent is not to say "get the hell out of here",
but it's STILL not a "welcome message". I mean the message is welcome,
but it doesn't say "welcome". IYSWIM. Would "redirection message" be
better?

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"I said 'play as you've never played before', not 'play as IF you've never
played before'!"
- Andy Capp
Nov 14 '05 #6

P: n/a
Joona I Palaste <pa*****@cc.helsinki.fi> writes:
Ben Pfaff <bl*@cs.stanford.edu> scribbled the following:
"osmium" <r1********@comcast.net> writes:
There must be a better phrase than "Welcome message" for a message that says
"Get the hell out of here". This is not in keeping with the avowed intent
of the owners of this newsgroup of being precise.

The intent of the message is *not* to say "get the hell out of
here". It is intended to, as gently as possible, explain why the
OP's article does not fall within clc's topic and guide the OP
to places on the net that better match his question. It is not
perfect, so suggestions for improvement are welcome.


You are right that its intent is not to say "get the hell out of here",
but it's STILL not a "welcome message". I mean the message is welcome,
but it doesn't say "welcome". IYSWIM. Would "redirection message" be
better?


I've used "off-topic guidance" - comments?
--
"It wouldn't be a new C standard if it didn't give a
new meaning to the word `static'."
--Peter Seebach on C99
Nov 14 '05 #7

P: n/a
Ben Pfaff <bl*@cs.stanford.edu> scribbled the following:
Joona I Palaste <pa*****@cc.helsinki.fi> writes:
Ben Pfaff <bl*@cs.stanford.edu> scribbled the following:
> "osmium" <r1********@comcast.net> writes:
>> There must be a better phrase than "Welcome message" for a message that says
>> "Get the hell out of here". This is not in keeping with the avowed intent
>> of the owners of this newsgroup of being precise.
> The intent of the message is *not* to say "get the hell out of
> here". It is intended to, as gently as possible, explain why the
> OP's article does not fall within clc's topic and guide the OP
> to places on the net that better match his question. It is not
> perfect, so suggestions for improvement are welcome.


You are right that its intent is not to say "get the hell out of here",
but it's STILL not a "welcome message". I mean the message is welcome,
but it doesn't say "welcome". IYSWIM. Would "redirection message" be
better?

I've used "off-topic guidance" - comments?


Yes. I like that.
(Bonus points to anyone who can name the computer game that uses that as
a sample.)

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"You have moved your mouse, for these changes to take effect you must shut down
and restart your computer. Do you want to restart your computer now?"
- Karri Kalpio
Nov 14 '05 #8

P: n/a
On Fri, 2 Jan 2004 12:57:44 -0800, "osmium" <r1********@comcast.net>
wrote in comp.lang.c:
Christopher Benson-Manica writes:
golson <go****@worldnet.att.net> spoke thus:
I have written a C function to copy a flash write routine that is in
Flash memory to RAM memory. I have then created a function that
uses a Function Pointer to run the copied function in RAM.

etc.


(The below welcome text was originally written by Ben Pfaff)


There must be a better phrase than "Welcome message" for a message that says
"Get the hell out of here". This is not in keeping with the avowed intent
of the owners of this newsgroup of being precise.


[snip]

There must be a better method of posting then over-quoting many, many
lines of material after your added comment.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
Nov 14 '05 #9

P: n/a
"Ben Pfaff" <bl*@cs.stanford.edu> wrote in message
news:87************@pfaff.stanford.edu...
Joona I Palaste <pa*****@cc.helsinki.fi> writes:
Ben Pfaff <bl*@cs.stanford.edu> scribbled the following:
"osmium" <r1********@comcast.net> writes:
> There must be a better phrase than "Welcome message" for a message
> that says "Get the hell out of here". This is not in keeping with
> the avowed intent of the owners of this newsgroup of being precise.

The intent of the message is *not* to say "get the hell out of
here". It is intended to, as gently as possible, explain why the
OP's article does not fall within clc's topic and guide the OP
to places on the net that better match his question. It is not
perfect, so suggestions for improvement are welcome.


You are right that its intent is not to say "get the hell out of here",
but it's STILL not a "welcome message". I mean the message is welcome,
but it doesn't say "welcome". IYSWIM. Would "redirection message" be
better?


I've used "off-topic guidance" - comments?


Deventer (n.) A decision that's very hard to take because so little depends
on it - like which way to walk round a park.

- The Deeper Meaning of Liff, Adams & Lloyd

<g>

--
Peter
Nov 14 '05 #10

P: n/a


Is it really necessary for both you and Ben Pfaff to post this to every
thread that is OT? One should be sufficient. Perhaps you should come
up with an algorithm to decide who will do it. Counting 1 bits in the
ASCII representation of the reply to address perhaps. Or maybe just
alternate odd and even days to save time and code space.

--
Randy Howard
2reply remove FOOBAR

Nov 14 '05 #11

P: n/a
Randy Howard wrote:

Is it really necessary for both you and Ben Pfaff to post this to every
thread that is OT? One should be sufficient. Perhaps you should come
up with an algorithm to decide who will do it. Counting 1 bits in the
ASCII representation of the reply to address perhaps. Or maybe just
alternate odd and even days to save time and code space.


I suggest we loose Ben immediately (he originated it).
Christopher is required to wait until 2 hours past the time the
message was apparently posted. The unwashed public is required to
wait 4 hours, and is restricted from posting if Chris or Ben have
been there first. :-)

This assumes all have newsreaders that properly translate posting
time into local time, or that maintain GMT throughout.

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
Nov 14 '05 #12

P: n/a
CBFalconer <cb********@yahoo.com> spoke thus:
I suggest we loose Ben immediately (he originated it).
Christopher is required to wait until 2 hours past the time the
message was apparently posted. The unwashed public is required to
wait 4 hours, and is restricted from posting if Chris or Ben have
been there first. :-)


Um, I can work with that :) (this was the first time I noticed a
double welcome message, but I may have missed others...)

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Nov 14 '05 #13

P: n/a
Ben Pfaff wrote:
You are right that its intent is not to say "get the hell out of here",
but it's STILL not a "welcome message". I mean the message is welcome,
but it doesn't say "welcome". IYSWIM. Would "redirection message" be
better?


I've used "off-topic guidance" - comments?


When I first saw this, it seemed to me that it meant the /guidance/ was
off-topic, which it isn't.

On the other hand, I can't at present think of anything better. If I get
inspired, I'll let you know.

--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 14 '05 #14

P: n/a
"Richard Heathfield" <do******@address.co.uk.invalid> wrote:
Ben Pfaff wrote:
I've used "off-topic guidance" - comments?


When I first saw this, it seemed to me that it meant the /guidance/ was
off-topic, which it isn't.


Oh, those ambiguities in English! How would you, for example, translate
"new car sale"? What exactly is "new" - the "cars" or the "sale"? ;-)
Nov 14 '05 #15

P: n/a
CBFalconer wrote:
This assumes all have newsreaders that properly translate posting
time into local time, or that maintain GMT throughout.


That's just two different ways of saying the same thing.

--
Richard Heathfield :-) bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 14 '05 #16

P: n/a
Peter Pichler wrote:
"Richard Heathfield" <do******@address.co.uk.invalid> wrote:
Ben Pfaff wrote:

I've used "off-topic guidance" - comments?


When I first saw this, it seemed to me that it meant the
/guidance/ was off-topic, which it isn't.


Oh, those ambiguities in English! How would you, for example,
translate "new car sale"? What exactly is "new" - the "cars" or
the "sale"? ;-)


It's like those "pre-owned" car sales. "They" want money for
them. However, I draw the inference that non-pre-owned cars have
no owner, and thus can be taken at will.

I think the odds are already favoring the honesty of the used car
dealer over the pre-owned car dealer. Not by much, though.

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!

Nov 14 '05 #17

P: n/a
On Sat, 3 Jan 2004 08:55:41 -0000, in comp.lang.c , "Peter Pichler"
<pi*****@pobox.sk> wrote:
"Richard Heathfield" <do******@address.co.uk.invalid> wrote:
Ben Pfaff wrote:
> I've used "off-topic guidance" - comments?


When I first saw this, it seemed to me that it meant the /guidance/ was
off-topic, which it isn't.


Oh, those ambiguities in English! How would you, for example, translate
"new car sale"? What exactly is "new" - the "cars" or the "sale"? ;-)


delightfully, the answer is "both, depending on context". ObC: its a
bit like a comma in C.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 14 '05 #18

P: n/a
Richard Heathfield <do******@address.co.uk.invalid> writes:
CBFalconer wrote:
This assumes all have newsreaders that properly translate posting
time into local time, or that maintain GMT throughout.


That's just two different ways of saying the same thing.


That's easy for you to say. Just wait until we all move to GMTland to
avoid the confusion; it'll be so crowded you won't even be able to see
your clocks.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
(Note new e-mail address)
Nov 14 '05 #19

P: n/a
Richard Heathfield <do******@address.co.uk.invalid> wrote:
Ben Pfaff wrote:
I've used "off-topic guidance" - comments?


When I first saw this, it seemed to me that it meant the /guidance/ was
off-topic, which it isn't.

On the other hand, I can't at present think of anything better. If I get
inspired, I'll let you know.


What about "topicality guidance"?

Richard
Nov 14 '05 #20

This discussion thread is closed

Replies have been disabled for this discussion.