-
-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
int not write or read properly #2
Comments
fixed by PR #3 |
Ues, maybe deleting the define and writing a note on README and examples is better option. I'll merge changes and update all ASAP, today was holiday in Catalonia. |
P.D.: I'll test on Maple, as I have a board here... |
Removed old code for STM32 that seems not be needed anymore on new Arduino_STM32 versions.
Tested with new release, 4.0.2:
If still failing recheck wiring and its length. Also, I didn't integrate read/write in template to save code space at expense of one stack space; if you use multiple datatypes program space will grow too much if you do all procesing on template instead using the 1-byte function. |
Wow! Still failing on int! |
OK, see the problem: On Arduino IDE default int size is 2 bytes: https://www.arduino.cc/reference/en/language/variables/data-types/int/ But when loading STM32 layer int size is changed to 4 bytes. This leads to this warning:
Problem is that when running the sketch "sizeof(int)" gives 4, as it is in STM32. The only fix I can find is to hardcode this case on STM32 (only), but still will fail in a direct assignment in sketch because compiler. |
wow. thank you! may be using int16_t \ uint16_t instead int may help.. |
No, it is something related to typecasting when using integer values (floats doesn't fail). I've accomplished what seems to be a correct write functionality using bit displacement, now I'm working on read functionality, as seems to fail too. |
I accomplished to fix everything on STM32. I need to re-add Wire.begin fix to STM32 in order to 1st read don't fail. I've no idea why, but if I remove it program fails reading 1st EEPROM value. Issues seems to be typecasting and byte ordering. Still needs to be tested on ESP8266 and AVR, so I have not created a release. |
Solved on trunk for STM32, Ardiono AVR and Arduino SAM. Checking for ESP8266.... |
OK! Tested on: STM32 All works. If yo have any trouble with wire.init() on library constructor you can call constructor with a FALSE on 1st parameter (all constructors) to skip it. Released as 4.1.0: https://github.com/Naguissa/uRTCLib/releases/tag/4.1.0 |
hello. My hands got to DS3231.
I try read and write to eeprom. Float and char work fine. Strange, but int - not.
void setup() {
int inttmp = 32101;
float floattmp = 3.14159;
char chartmp = 'A';
if (!rtc.eeprom_write(0, inttmp)) {
Serial.println("Failed to store INT");
}
if (!rtc.eeprom_write(4, floattmp)) {
Serial.println("Failed to store FLOAT");
}
if (!rtc.eeprom_write(8, chartmp)) {
Serial.println("Failed to store CHAR");
}
nttmp = 0;
floattmp = 0;
chartmp = 0;
Serial.print("int: ");
rtc.eeprom_read(0, &inttmp);
Serial.print(inttmp);
Serial.print("; float: ");
rtc.eeprom_read(4, &floattmp);
Serial.print(floattmp);
Serial.print("; char: ");
rtc.eeprom_read(8, &chartmp);
Serial.print(chartmp);
Serial.println();
receive this
int: 65535; float: 3.14; char: A
The text was updated successfully, but these errors were encountered: