McChubby007 wrote:OK.
Is the variable you are changing in the isr a simple data type (int etc) and is it marked as 'volatile' in the global declaration of it? It also has to be 'atomic' which means a read/write to a variable with a bit size smaller or same as the architecture which in this case is 32 bit. Also, is it aligned on the correct memory boundary, and if yu comment out the access to the variable in just the main code (or the idr) does the wdt reset go away?
Yes, a simple example replicating the problem is always a good start - it is something us 'professionals' will do when other methods of fault detection fail.
Hello McChubby007!
Thanks for the answers.
Something is happening with my account and I do not receive replies by email.
Just seen it now.
I thought about doing a brief program to explain the problem, but I will not be able to provoke the problem here, since I am traveling (away from the company).
But it's really really simple stuff that I do and I do not understand why the problem happens.
Within the interruption, a variable is incremented.
I tested it with 'volatile' but it did not change anything.
This part I did not understand, can you explain me better? "It also has to be 'atomic' which means to read / write to a variable with a bit size smaller or same as the architecture which in this case is 32 bit."
when you say: "Also, is it aligned on the correct boundary memory, and if it's commenting on the access to the variable in just the main code (or the idr) does the wdt reset go away?"
is it for me to leave the variable incrementing, but not to use it anywhere to make a test if the problem appears? I did not take this test! Good idea, I'll code and send it to my colleagues to test it.
Would you prefer me to open a new topic?
I put it here because I thought about solving it by reading the interrupt flag and incrementing myself the variable, without ISR.
I will paste here the passages involved in this error, where I use the variable, maybe it will facilitate the understanding.
pinMode(pin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(pin), interrupcaoED1, FALLING);
inside h file
{
extern volatile uint32_t pulsosEDs[8];
extern volatile bool entradasDigitais[8];
}
cpp file
{
volatile uint32_t pulsosEDs[8];
volatile bool entradasDigitais[8];
}
void interrupcaoED1()
{
pulsosEDs[0]++;
entradasDigitais[0] = 1;
}
recording the variable in the file:
uint32_t *uint32_tBuffer;
uint32_tBuffer = (uint32_t *)malloc(((readings[readingIndex].numRegs * sizeof(uint32_t)) + 1));
uint32_tBuffer[0] = pulsosEDs[readings[readingIndex].reg];
pulsosEDs[readings[readingIndex].reg] = 0;
auxPtr = (char *)&uint32_tBuffer[0];
auxPtr[sizeof(uint32_t) * readings[readingIndex].numRegs] = 0;
carregaArquivos.write((const uint8_t *)auxPtr, ((sizeof(uint32_t) * readings[readingIndex].numRegs) + 1));
free(uint32_tBuffer);
break;