In this funcition the "int sala49" is usualy zero and nothing major happen, but when it turns into a number different from zero It consumes memory from the Arduino, and it eventualy runs out of It and resets within three hours of operation (someting that cannot happen). There are 10 millis functions like the shown here and all of them is executed every 10 minutes at the same time (that is the maximum interval that I can work with).
I would like to know if Arduino volatile memory can be expanded easly or exist other time function that doesn't fill the Arduino memory with "trash".
I've tried all the possibillities for this problem, and all the tests lead to the millis function.
I don't know why but ia appears that this function uses a little bit of the arduino flash memory every time that it's executed and the variable sala49 ins greater than 0.
There are inexpensive FRAM modules, I use 8 x 32K on the I2C bus. I can use 8 of them. They are also available on SPI. When powering down they will remember just like EEPROM but they are much faster, no delay in read or write, and over a billion cycles.
Thank's for the advice!
But could It be used yust as an expansion of the existing memory. Without the need of making the code write or read things on it?
Because It's not actual useful data thai is consuming the Arduino memory but rather is yust "trash" that is coming from the millis function.
This is the specific part of the code that is giving me trouble. Specialy the "void tempo"
void tempo(){
if (sala48 > 0){ //Caso a variável sala 48 for maior que zero.
if ((millis() - millisala48) > ((sala48-48)*3000000)){ //Caso a fução millis menos a fução millis da sala 48 seja maior que o número de aulas digitado (é feita a conversão de aulas para milli segundos, considerando que a duração de uma aula seja 50 minutos).
sala48 = 0; //A variável sala48 é mudada para 0.
mega1.shiftWrite(1, HIGH);
mega1.shiftWrite(2, LOW); //O LED verde é aceso e o LED vermelho é apagado. //A variável rest48 é mudada para 1.
}
}
if (sala49 > 0){
if ((millis() - millisala49) > ((sala49-48)*3000000)){
sala49 = 0;
mega1.shiftWrite(3, HIGH);
mega1.shiftWrite(4, LOW);
}
}
if (sala50 > 0){
if ((millis() - millisala50) > ((sala50-48)*3000000)){
sala50 = 0;
mega1.shiftWrite(5, HIGH);
mega1.shiftWrite(6, LOW);
}
}
if (sala51 > 0){
if ((millis() - millisala51) > ((sala51-48)*3000000)){
sala51 = 0;
mega1.shiftWrite(7, HIGH);
mega1.shiftWrite(8, LOW);
}
}
if (sala52 > 0){
if ((millis() - millisala52) > ((sala52-48)*3000000)){
sala52 = 0;
mega1.shiftWrite(9, HIGH);
mega1.shiftWrite(10, LOW);
}
}
if (sala53 > 0){
if ((millis() - millisala53) > ((sala53-48)*3000000)){
sala53 = 0;
mega1.shiftWrite(11, HIGH);
mega1.shiftWrite(12, LOW);
}
}
if (sala54 > 0){
if ((millis() - millisala54) > ((sala54-48)*3000000)){
sala54 = 0;
mega1.shiftWrite(13, HIGH);
mega1.shiftWrite(14, LOW);
}
}
if (sala55 > 0){
if ((millis() - millisala55) > ((sala55-48)*3000000)){
sala55 = 0;
mega1.shiftWrite(15, HIGH);
mega1.shiftWrite(16, LOW);
}
}
if (sala56 > 0){
if ((millis() - millisala56) > ((sala56-48)*3000000)){
sala56 = 0;
mega1.shiftWrite(17, HIGH);
mega1.shiftWrite(18, LOW);
}
}
if (sala57 > 0){
if ((millis() - millisala57) > ((sala57-48)*3000000)){
sala57 = 0;
mega1.shiftWrite(19, HIGH);
mega1.shiftWrite(20, LOW);
}
}
mensageminicial();
}
void mensageminicial(){
for (counter = 0; counter < 42; ++counter) {
if ( ! mfrc522.PICC_IsNewCardPresent()) //Caso nenhuma TAG seja lida.
{
lcd.clear();
lcd.setCursor(1, 0);
lcd.print("Hora: ");
lcd.print(rtc.now().hour());
lcd.print(":");
lcd.setCursor (10,0);
lcd.print(rtc.now().minute());
lcd.print(":");
lcd.print(rtc.now().second());
lcd.setCursor(0, 2);
lcd.print("Data: ");
lcd.print(rtc.now().day());
lcd.print("/");
lcd.print(rtc.now().month());
lcd.print("/");
lcd.print(rtc.now().year());
delay(5000); //Mostra hora e data e aguarda 7 segundos.
if ( ! mfrc522.PICC_IsNewCardPresent()) //Caso nenhuma TAG seja lida.
{
lcd.clear();
lcd.print("Temp.: ");
lcd.print(bmp.readTemperature());
lcd.println(" *C ");
delay(5000); //Mostra a Temperatura e aguarda 7 segundos.
if ( ! mfrc522.PICC_IsNewCardPresent()) //Caso nenhuma TAG seja lida.
{
lcd.clear();
lcd.setCursor(1, 0);
lcd.print("Insira a TAG"); //Mostra a mensagem "Insira a TAG".
}else{
tag();
}
}else{
tag();
}
}else{
tag();
} //Caso alguma TAG seja lida, é executada a fução void tag.
delay (5000); //Aguarda 7 segundos
}
tempo();
}
Is salaxx a char?
Why don't you perform the salaxx-48 operation when you enter the character and directly store the decimal value it represents?
It's because of things like this that code fragments are useless.
You have been struggling with the same program for at least two months, and you are still not providing the information this community needs to help you...
This line has definitely incorrect math in it, because the overflow in the last parenthesis.
Without correcting these errors there is no point in moving forward.
It appears your knowledge of microcontrollers is very limited. You cannot read or write any memory without writing code to do it. When coming out of reset it will fetch an instruction at a known location, after that it is your code that does its thing. If you read the data sheet on the processor you would have found that it does not have the internal busses pined out so there is no way to add additional memory into the existing memory map. The FRAM libraries are well written and the I/O is transparent to your program.