Hi
I am now stranded for more than one month solving a RAM trouble, would You please kindly help me ?
Working on a remote low power data collector, I was enthralled to test the RTC HV-1805-C3.
In sleep mode deconnecting the Arduino’s power supply, consuming only 22 nanoAmps from a super capacitor, and providing a generous 512 bytes RAM.
Sadly, I can’t use more than 256 bytes instead of 512
According to the application manual,
https://cdn.sparkfun.com/assets/0/8/4/2 /f/RV-1805-C3_App-Manual.pdf
the RTC is providing 2 sorts of RAM.
A six bit RAM from adress 0x40 to 0x7F, in 4 partitions of 64 bytes. The 2 upper bits being provided in adress 3F by the 2 XADS bits number 0 and 1.
A seven bit RAM from adress 0x80 to 0xFF in 2 partitions of 128 bytes. The upper bit being provided in adress 3F by the XADA bit number 2.
Attached : REGISTER 0x3F and REGISTERS 0x40 – 0xFF
I am using commonplace functions to write and read the bytes.
uint8_t RV::readByteFromRegister(uint8_t address) {
uint8_t value = 0;
_i2cPort->beginTransmission(RV_ADDRESS);
_i2cPort->write(address);
_i2cPort->endTransmission(false);
_i2cPort->requestFrom(RV_ADDRESS, 1);
value = _i2cPort->read();
_i2cPort->endTransmission();
///Serial.print("_"); Serial.print(address);
return value;
}
bool RV::writeByteToRegister(uint8_t address, uint8_t value) {
///Serial.print("_"); ///Serial.println(readByteFromRegister(0x3F));
_i2cPort->beginTransmission(RV_ADDRESS);
_i2cPort->write(address);
_i2cPort->write(value);
return (_i2cPort->endTransmission() == 0);
}
This test , writing 0 in the first Standard RAM partition, 1 in the second, 2 in the third and 3 in the fourth partition.
Then writing 4 in the first Alternate RAM partition and 5 in the second partition.
byte value = rtc.readByteFromRegister(0x3F);
//**************** WRITING STANDARD RAM**************************///
value &= 0b11111100; rtc.writeByteToRegister(0x3F,value);
for (byte i=0; i<64; i++) { byte a = 64 + i; rtc.writeByteToRegister(a, 0); }
value = rtc.readByteFromRegister(0x3F); value |= (0b01 << 0); rtc.writeByteToRegister(0x3F,value);
for (byte i=0; i<64; i++) { byte a = 64 + i; rtc.writeByteToRegister(a, 1); }
value = rtc.readByteFromRegister(0x3F); value |= (0b10 << 0); rtc.writeByteToRegister(0x3F,0x2);
for (byte i=0; i<64; i++) { byte a = 64 + i; rtc.writeByteToRegister(a, 2); }
value = rtc.readByteFromRegister(0x3F); value |= (0b11 << 0); rtc.writeByteToRegister(0x3F,value);
for (byte i=0; i<64; i++) {byte a = 64 +i; rtc.writeByteToRegister(a, 3); !rtc.writeByteToRegister(a+64, 9); }
//*******************WRITING ALTERNATE RAM *************************///
value = rtc.readByteFromRegister(0x3F); value &= 0b11111011; rtc.writeByteToRegister(0x3F,value);
for (byte i=0; i<128; i++) {byte a = 128 + i; rtc.writeByteToRegister(a, 4);}
value = rtc.readByteFromRegister(0x3F); value &= 0b11111011;value |= (1 << 2); rtc.writeByteToRegister(0x3F,value);
for (byte i=0; i<128; i++) { byte a = 128 + i; rtc.writeByteToRegister(a,5 ); }
//******************* READING STANDARD RAM *************************///
rtc.writeByteToRegister(0x3F,0x0); Serial.println(rtc.readByteFromRegister(0x3F));
for (byte i=0; i<64; i++) { byte a = 64 + i; Serial.print(","); Serial.print(rtc.readByteFromRegister(a));Serial.print("_"); Serial.print(a); } Serial.println(" ");
rtc.writeByteToRegister(0x3F,0x1); Serial.println(rtc.readByteFromRegister(0x3F));
for (byte i=0; i<64; i++) { byte a = 64 + i; Serial.print(","); Serial.print(rtc.readByteFromRegister(a));Serial.print("_"); Serial.print(a); } Serial.println(" ");
rtc.writeByteToRegister(0x3F,0x2); Serial.println(rtc.readByteFromRegister(0x3F));
for (byte i=0; i<64; i++) { byte a = 64 + i; Serial.print(","); Serial.print(rtc.readByteFromRegister(a));Serial.print("_"); Serial.print(a); } Serial.println(" ");
rtc.writeByteToRegister(0x3F,0x3); Serial.println(rtc.readByteFromRegister(0x3F));
for (byte i=0; i<64; i++) { byte a = 64 + i; Serial.print(","); Serial.print(rtc.readByteFromRegister(a));Serial.print("_"); Serial.print(a); } Serial.println(" ");
//****************** READING ALTERNATE RAM **************************///
rtc.writeByteToRegister(0x3F,0x0); Serial.println(rtc.readByteFromRegister(0x3F));
for (byte i=0; i<128; i++) { byte a = 128 + i; Serial.print(","); Serial.print(rtc.readByteFromRegister(a));Serial.print("_"); Serial.print(a); } Serial.println(" ");
rtc.writeByteToRegister(0x3F,0x4); Serial.println(rtc.readByteFromRegister(0x3F));
for (byte i=0; i<128; i++) { byte a = 128 + i; Serial.print(","); Serial.print(rtc.readByteFromRegister(a)); Serial.print("_"); Serial.print(a); } Serial.println(" ");
Attached, sheet result 1, the Alternate RAM has overwritten the Standard RAM.
If writing first the Alternate RAM and then the Standard RAM, the Alternate RAM is overwritten. Attached sheet result 2.
THE STANDARD RAM IS OVERWRITING THE ALTERNATE RAM and vice versa.
I am completely lost and wondering whether there is some magic in the chip or more probably I am doing something wrong. Can somebody help me please?
Thanks a lot.
JB