Pages: 1 [2]   Go Down
Author Topic: SRAM interface question  (Read 912 times)
0 Members and 1 Guest are viewing this topic.
nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8473
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

My C++ is very rusty to non-existent but I reckon you could create a class with an internal data structure as required, then overload the = operator with code that read/writes to the external RAM so at the source level it almost looks like normal code. Like

XM.some_var = 1234;



______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Melbourne, Australia
Offline Offline
God Member
*****
Karma: 8
Posts: 567
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

My C++ is very rusty to non-existent but I reckon you could create a class with an internal data structure as required, then overload the = operator with code that read/writes to the external RAM so at the source level it almost looks like normal code. Like

XM.some_var = 1234;



______
Rob

The variable would have to know where free space was, and once used, return it to free space. An array of such variable might help with that.
Logged

Windows serial port monitor: Tellurium | Arduino serial port debugging library: DBG | Cusom LCD char generator | Technical questions will only be answered in forum threads

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

Yes, I'm assuming static data so knowing where free space is would not be an issue.

A "variable" could use offsetof() to determine it's location in the struct and therefore the XM, but this approach would need functions for the various variable types and I don't know how you would differentiate between variables of the same type.

It would get very messy I think unless a C++ guru can advise otherwise.

Certainly an array of same types would be a lot easier.

And of course if you can fit the struct in internal RAM there's little point in having the external RAM in the first place smiley

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Offline Offline
Jr. Member
**
Karma: 0
Posts: 64
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Between oric_dan and aarondc's comments (thank you both) I've been able to get the following to work:
Code:
 for(int i=0; i<7; i++) {
    unsigned int rw_addr = exIntAry0+(i*sizeof(int));
    writeRamInt(i, rw_addr, sizeof(int));
  }

  for(int i=0; i<7; i++) {
    unsigned int rw_addr = exIntAry0+(i*sizeof(int));
    int numb = readRamInt(rw_addr, sizeof(int));
    Serial.print(F("numb= "));
    Serial.println(numb);
  }
The problem is, you have to program how many elements the array has...  ...any ideas on how to solve this issue?
« Last Edit: May 24, 2013, 10:49:20 pm by sparkfuntoday » Logged

Pages: 1 [2]   Go Up
Jump to: