We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello, I developed an emmbedded application for a C167CR-LM. In this application I've some very big data structures stored in internal RAM (IDATA) and some dynamic list managed using malloc and free. For dynamic allocation I define the pool:
unsigned char far equivalence_pool[0x4000]; init_mempool (equivalence_pool, sizeof (equivalence_pool));
In my application there is a IRQ routine on a Timer T6 with a period of 0.5 ms.
In some situations the ILLOPA exception is trapped an the application crashes. It generally happens when many digital input (linked to port P2 pins) are active together.
I tried to increase the user stack with no effect.
Adding 2 calls to printf in the IRQ routine, ILLOPA is not generated.
Have you some suggestions for help me how to investigate this problem?
Testing with Mon166 the trap routines are not available, and using Simulator is too complex cause the hardware and input sequences to generate.
Thanks, Marco
Here the 5/5 part of the code:
// ================== GESTIONE RILETTURA USCITE ====================== if (NOutputSpeed) { if (!RB_Cnt) { // controllo della rilettura di tutte le uscite checkRB = ((~Output) ^ P5) & MaskOutSpeed; for (i=0; i<NOutputSpeed; i++) { if (EnableRB[i] && (checkRB & (1<<i))) { CountErrRB++; errRB =1; } } RB_Cnt = NO_COUNT; } if (RB_Cnt != NO_COUNT) RB_Cnt--; } // ===================== GESTIONE RITARDI =========================== if (NDly) { // gestione canali ritardati for (i=0; i<NDly; i++) { // se nel ciclo precedente è cambiato lo stato dell'uscita viene // controllato se si è verificato un errore di rilettura (se abilitata) if(EnableRB[Dly[i].Output] && (!Dly[i].Status)) { if(((~Output) ^ P5) & (0x0001 << Dly[i].Output)) { CountErrRB++; errRB = 1; } Dly[i].Status = NO_COUNT; } if (Dly[i].Status != NO_COUNT) Dly[i].Status--; if (Dly[i].Encoder == 0xFF) { // -------------- Ritardi a tempo ------------------------------- if (Dly[i].CountDlyOn != NO_COUNT) { Dly[i].CountDlyOn--; if (Dly[i].CountDlyOn < 0) { Output |= (0x0001 << Dly[i].Output); Dly[i].Status = RB_DELAY; Dly[i].CountDlyOn = NO_COUNT; } } if (Dly[i].CountDlyOff != NO_COUNT) { Dly[i].CountDlyOff--; if (Dly[i].CountDlyOff < 0) { Output &= ~(0x0001 << Dly[i].Output); Dly[i].Status = RB_DELAY; Dly[i].CountDlyOff = NO_COUNT; } } } else { // -------------- Ritardi a spazio (encoder) ---------------------- if (Dly[i].CountDlyOn != NO_COUNT) { cnt = abs(countEnc - countON[i]); if (cnt > MAX_GAP) Dly[i].CountDlyOn -= (countEnc > MAX_GAP) ? (0xFF - countEnc + countON[i]): (0xFF + countEnc - countON[i]); else Dly[i].CountDlyOn -= cnt; // Dly[i].CountDlyOn -= abs(countEnc - countON[i]); countON[i] = countEnc; if (Dly[i].CountDlyOn <= 0) { Output |= (0x0001 << Dly[i].Output) ; Dly[i].Status = RB_DELAY; Dly[i].CountDlyOn = NO_COUNT; } } if (Dly[i].CountDlyOff != NO_COUNT) { cnt = abs(countEnc - countOFF[i]); if (cnt > MAX_GAP) Dly[i].CountDlyOff -= (countEnc > MAX_GAP) ? (0xFF - countEnc + countOFF[i]): (0xFF + countEnc - countOFF[i]); else Dly[i].CountDlyOff -= cnt; // Dly[i].CountDlyOff -= abs(countEnc - countOFF[i]); countOFF[i] = countEnc; if (Dly[i].CountDlyOff <= 0) { Output &= ~(0x0001 << Dly[i].Output); Dly[i].Status = RB_DELAY; Dly[i].CountDlyOff = NO_COUNT; } } } } // attuazione dei canali di uscita SetOut(Output); } // trasmissione su CAN della condizione di errore sul PDO di stato // se si è verificato almeno un errore di rilettura if (errRB && (!(Stato & ERROR_RB))) { T8R = 1; Stato |= ERROR_RB; CAN_MSGOBJ[STATO].msg_ctl = CPUUPD_SET; CAN_MSGOBJ[STATO].msg_cfg = MSG_CFG(1, CANDIR_TRANSMIT, 0); CAN_MSGOBJ[STATO].msg[0] = Stato; CAN_MSGOBJ[STATO].msg_ctl = CPUUPD_CLR & TXRQ_SET; } StartT1Idle = T1; }