Pages: [1]   Go Down
Author Topic: How to fit a variable in a fixed position in ram  (Read 495 times)
0 Members and 1 Guest are viewing this topic.
NZ
Offline Offline
Jr. Member
**
Karma: 1
Posts: 91
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How do I assign variables to a fixed location in ram in C ?

I have a quite a few variables declared as static and what I would like to do is to place these variables in a set order and then later send these via serial in a set order by starting a ram address xx

Or should I just let the compiler take care of this ?

Ta

Kim

Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17262
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well I would think letting the compiler take care of it, or at most use C pointer would be more then adequate to the task. Why you would want to add the burden to handle raw addressing of flash memory. seems like a flashback bad trip back towards assembly language. As as serial transmission is slower then processor time, what is the point or advantage gained?

Lefty
Logged

NZ
Offline Offline
Jr. Member
**
Karma: 1
Posts: 91
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Main reason is debugging really, dump 50 bytes etc., but also after speed, tho with the 32bit Due this is probably not going to be much of an issue.
But you are right, I do get flashbacks, lots at times.

Do I have to do it in Assembly or can this be done in C ?
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8472
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You should be able to set a pointer to any place in memory, maybe something like this

byte * ptr  = (byte*)(0x1234);

That's probably not right, I always have to try every possible combination of these things to get the right syntax smiley

But really what do you care where things are? It won't be any faster. Unless you have to address memory-mapped hardware it seems like an exercise in futility.

If your data elements are all the same use an array, if not use a structure.

______
Rob
« Last Edit: December 05, 2012, 10:28:03 am by Graynomad » Logged

Rob Gray aka the GRAYnomad www.robgray.com

NZ
Offline Offline
Jr. Member
**
Karma: 1
Posts: 91
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just really my lack of knowledge of C, but its improving heaps

Thanks
Logged

Pages: [1]   Go Up
Jump to: