Go Down

Topic: SRAM interface question (Read 1 time) previous topic - next topic

Graynomad

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
Rob Gray aka the GRAYnomad www.robgray.com

aarondc


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.
Windows serial port monitor: Tellurium | Arduino serial port debugging library: DBG | Cusom LCD char generator | Technical questions will only be answered in forum threads

Graynomad

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 :)

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

sparkfuntoday

#18
May 25, 2013, 05:21 am Last Edit: May 25, 2013, 05:49 am by sparkfuntoday Reason: 1
Between oric_dan and aarondc's comments (thank you both) I've been able to get the following to work:
Code: [Select]

 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?

Go Up