-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
Use of this lib for stm32l476 in shutdown mode #7
Comments
Dear Axoul,
To be honest, I don't know if it works. I never tried anything with sleeping mode, so you would have to try yourself I'm afraid.
I'm glad at least you easily could port it to your L476.
Kind regards,
Michel
…________________________________
Van: axoulc <[email protected]>
Verzonden: donderdag 25 februari 2021 13:58
Aan: nimaltd/ee <[email protected]>
CC: Subscribed <[email protected]>
Onderwerp: [nimaltd/ee] Use of this lib for stm32l476 in shutdown mode (#7)
Hello and thanks for your library.
I tried to adapt it to L476 with the following parameters :
#define _EE_USE_FLASH_PAGE_OR_SECTOR (255)
...
#if defined(STM32L476xx)
#define _EE_SIZE 2048
#define _EE_ADDR_INUSE (((uint32_t)0x08000000) | (_EE_SIZE * _EE_USE_FLASH_PAGE_OR_SECTOR))
#define _EE_FLASH_BANK FLASH_BANK_1
#define _EE_PAGE_OR_SECTOR PAGE_NUM
#if (_EE_USE_FLASH_PAGE_OR_SECTOR > 255)
#error "Please Enter correct address, maximum is (255)"
#endif
#endif
It works !
But I need to use your lib in order to backup some data to enter in shutdown mode. I had the following idea in a sort of algorithm :
* First boot : ee_init and ee_erase
* Before shutdown : write : first byte is the number of data written just after. Next bytes : data
* Sleep
* After shutdown : ee_init , read the first byte to know the size of the next reading. Read the following bytes according to the size
* Before shutdown : rewrite the first byte to the following append. Write after existing bytes new data.
Is this algorithm is possible according to your lib and flash caracteristics ?
Thanks in advance and sorry for my english
Axoul
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<#7>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ACAUYIHHDBC46YD65QAKH23TAZCNRANCNFSM4YGOUF6A>.
|
hi. do you execute ee_commit() ? you can write your data by ee_writeToRam() and ee_commit . |
ee_init(); |
Hi, thanks for your answer but the problem still the same. My code : typedef struct __packed {
time_t timestamp;
float temp;
float rand;
} loggerData_t; if(!startFromShutdown) {
RV3032_SetTimeDate(&rtc, 1616577571);
eepromInit();
RV3032_GetTemperature(&rtc);
RV3032_GetTimeDate(&rtc);
inData = (loggerData_t){rtc.lastEpoch, rtc.lastTemp, randFloat()};
printf("%f|%f\r\n", inData.temp, inData.rand); //debug
eepromAppend(&inData);
shutdownTimer(10);
} else {
if (eepromNbData() == 5) {
eepromToFlash();
} else {
RV3032_GetTemperature(&rtc);
RV3032_GetTimeDate(&rtc);
inData = (loggerData_t){rtc.lastEpoch, rtc.lastTemp, randFloat()};
printf("%f|%f\r\n", inData.temp, inData.rand); //debug
eepromAppend(&inData);
shutdownTimer(10);
}
} void eepromInit(void) {
uint8_t nb = 0;
ee_init();
ee_format(false);
ee_write(0, 1, &nb);
}
void eepromAppend(loggerData_t *newData) { // max 512 bytes (heap)
uint8_t nbData = eepromNbData();
uint8_t newNum = nbData + 1;
ee_writeToRam(0, 1, &newNum);
for (uint8_t i = 0, j = 1; i < nbData; i++, j += sizeof(loggerData_t)) {
loggerData_t buffer;
ee_read(j, sizeof(loggerData_t), (uint8_t*) &buffer);
ee_writeToRam(j, sizeof(loggerData_t), (uint8_t*) &buffer);
}
ee_writeToRam((1 + (nbData * sizeof(loggerData_t))), sizeof(loggerData_t),
(uint8_t*) newData);
ee_commit();
}
uint8_t eepromNbData(void) {
uint8_t nbData = 0;
ee_read(0, 1, &nbData);
return nbData;
}
void eepromToFlash(void) {
uint8_t nbData = eepromNbData();
for (uint8_t i = 0, j = 1; i < nbData; i++, j += sizeof(loggerData_t)) {
loggerData_t out;
ee_read(j, sizeof(loggerData_t), (uint8_t*) &out);
char uartBuffer[30];
sprintf(uartBuffer, "%ld,%.3f,%.3f\r\n", out.timestamp, out.temp,
out.rand);
HAL_UART_Transmit(&huart2, (uint8_t*) uartBuffer, strlen(uartBuffer),
1000);
}
eepromInit();
} This program append 5 times the struct to the existing data. After that it prints it :
Thanks in advance |
try this one
|
Hello and thanks for your library.
I tried to adapt it to L476 with the following parameters :
It works !
But I need to use your lib in order to backup some data to enter in shutdown mode. I had the following idea in a sort of algorithm :
ee_init
andee_erase
ee_init
, read the first byte to know the size of the next reading. Read the following bytes according to the sizeIs this algorithm is possible according to your lib and flash caracteristics ?
Thanks in advance and sorry for my english
Axoul
The text was updated successfully, but these errors were encountered: