Go Down

Topic: Library for RAM chip (Read 5208 times) previous topic - next topic

AWOL

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

farlepet


AWOL

_read isn't a function returning a reference, so the assignment isn't possible.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

farlepet

OK, so how would I make it so you could do a statement like: Serial.print(AM9111.read()); ?

AWOL

Code: [Select]
int AM9111::_read()
{
  digitalWrite(_odp,0);
  digitalWrite(_wep,1);
  int rv = 0;
  bitWrite(_rbits,0,digitalRead(_IO[0]));
  bitWrite(_rbits,1,digitalRead(_IO[1]));
  bitWrite(_rbits,2,digitalRead(_IO[2]));
  bitWrite(_rbits,3,digitalRead(_IO[3]));
  _read() = _rbits;
  return rv;
}

Have you ever thought why this routine would always return zero? (if it were to compile)
Is that what you want?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

farlepet

WHat i wanted was to have _read read the outputs of the ram and have _read = the output ex: out = 1101; _read = 13;

AWOL

#21
Apr 22, 2011, 11:42 pm Last Edit: Apr 22, 2011, 11:45 pm by AWOL Reason: 1
If that's what you wanted, why does it return zero?

Your _write method also (unusually) returns a value that is always zero.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

farlepet

I changed, but still has an error, do i have to have it do: return _rbits; ?

AWOL

Did you initialise _rbits?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

farlepet


AWOL

No, apart from the missing semicolon, that looks more like a declaration, not an initialisation.

The clue is, you did initialise a variable, but it wasn't _rbits.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

farlepet

so, how should i do it?

AWOL

I'd probably forget about _rbits altogether, and use (I mean really use) "rv".
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

farlepet


AWOL

By the way, the spelling is "indeterminate", not "intermediate".    ;-)
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy