Hi all,
I have an embedded system which is required to have memory partitioning due to safety reasons. Unfortunately there are sporadically bus address error exceptions. I am using a Motorola M68376 as a foreground/background system but I think it's no problem of the microprocessor. There are three asynchronous interrupt sources. Each of them has a different ISR assigned. The principle structure of each ISR is as follows:
void ISR_x(void) { PartCtrl(UNPROTECT_MEMORY); Foo(); PartCtrl(PROTECT_MEMORY); }
The function PartCtrl() looks like:
unsigned long UnprotectCnt = 0; /* mapped to a memory partition which is not affected by the memory protect mechanism */ void PartCtrl(char Flag) { switch (Flag) { case PROTECT_MEMORY: if (UnprotectCnt > 0) { UnprotectCnt--; } if (UnprotectCnt == 0) { SetMemoryToReadOnly(); } break;
case UNPROTECT_MEMORY: UnprotectCnt++; if (UnprotectCnt == 1) { SetMemoryToReadAndWrite(); } break; } }
What is wrong with this code? I tried to disable interrupts while beeing in the function PartCtrl() but this is no solution because the software has to recognize all interrupts otherwise different problems arise.
Thanks for your help.