How to use pointer in uC to decrease RAM size?

Status
Not open for further replies.

Help

Advanced Member level 2
Joined
Feb 15, 2005
Messages
617
Helped
7
Reputation
14
Reaction score
3
Trophy points
1,298
Activity points
7,065
Use pointer in uC

Hi,

Q1) Do you know how to solve the below problem? without adding any new declaration, is it possible?

Code:
void fc1(unsigned char *xp)
{
	fc2(&xp);
	...
	..
}
void fc2(unsigned char *yp)
{
...
..
}

Q2) how to use pointer to reduce the microcontroller RAM size? Do you got any exemple program?

Thank You
 

Re: Use pointer in uC

Help said:
Q1) Do you know how to solve the below problem? without adding any new declaration, is it possible?

I'm not sure what you are doing but I quess if you call fc2 like fc2(xp) it will works fine...?
 

Re: Use pointer in uC

SSK said:
call fc2 like fc2(xp)

But i can't change it to fc2(xp) because others function i pass with pointer * ( fc2(*yp)).

Thank You.
 

Re: Use pointer in uC

Not sure but it seems you are messing "*" as operator with "*" as declarator.

fc1 expect a pointer to uchar
fc2 also expect a pointer to uchar but you are passing the pointer address instead, a pointer to the stack finally since pointer is passed at function call and you even can't know there original pointer address, seems too scarce to be intended...

xp is still a pointer inside fc1, then fc2(xp) fulfill fc2 declaration (without "&" operator since xp is already a pointer) nevertheless fc2(&xp) would fulfill fc2( uchar **xp ) instead.

cheers ;-)
 

    Help

    Points: 2
    Helpful Answer Positive Rating
Re: Use pointer in uC

Hi

Thank you very much. At least we not need to add another variable to solve it.

So, do you know my Q2?
Thank You.
 

Re: Use pointer in uC

Since a pointer is a variable (uses ram) and it's a reference to values and not the values themselves (that use their own RAM/ROM), generally speaking I don't think pointers can help you to use less ram but less rom, since they let you fold together common parts of code making them dependant on a pointer value dinamically adjusted vs. rom fixed codes (ie address to jump).

Cheers ;-)
 

    Help

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…