Use ESR pins as a trap input

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User8750
Level 1
Level 1
We would like to use the ESR pins on the XE169FH as a trap input. A random number of interrupts seems to be handled ok but after repeating the trigger on the ESR pin for a while a hang-up appears. We are now already struggling for a long time with this hang-up. Does somebody have any suggestions or a source code example which we can look into?

Interrupt handler we are using:

_interrupt(BTRAP) void INT_viClassBTrap(void)
{
// USER CODE BEGIN (ClassBTrap,2)
// USER CODE END

if(TFR_SR1) // System Request 1
{
// USER CODE BEGIN (SR1Trap,1)
if (SCU_TRAPSTAT & SCS_MASK_TRAP_ESR0T) //ESR0 trap occurred?
{
MAIN_vUnlockProtecReg();

// Handle the trap
LED1(!_LED1); //Toggles an I/O pin with a LED

//Clear the request within DMP_M via DMPMITCLR
SCU_DMPMITCLR = SCS_MASK_INT_ESR0T;

//And then clear the request within DMP_1 via TRAPCLR
SCU_TRAPCLR = SCS_MASK_TRAP_ESR0T;

MAIN_vLockProtecReg();
}

if (SCU_TRAPSTAT & SCS_MASK_TRAP_ESR1T) //ESR1 trap occurred?
{
MAIN_vUnlockProtecReg();

// Handle the trap
LED2(!_LED2); //Toggles an I/O pin with a LED

// Clear the request within DMP_M via DMPMITCLR
SCU_DMPMITCLR = SCS_MASK_INT_ESR1T;

//And then clear the request within DMP_1 via TRAPCLR
SCU_TRAPCLR = SCS_MASK_TRAP_ESR1T;

MAIN_vLockProtecReg();
}

if (SCU_TRAPSTAT & SCS_MASK_TRAP_ESR2T) //ESR2 trap occurred?
{
// Handle the trap
LED3(!_LED3); //Toggles an I/O pin with a LED

MAIN_vUnlockProtecReg();

//Clear the request within DMP_M via DMPMITCLR
SCU_DMPMITCLR = SCS_MASK_INT_ESR2T;

//And then clear the request within DMP_1 via TRAPCLR
SCU_TRAPCLR = SCS_MASK_TRAP_ESR2T;

MAIN_vLockProtecReg();
}
// USER CODE END
TFR_SR1 = 0;

// USER CODE BEGIN (SR1Trap,2)
// USER CODE END
} // end of if System Request 1

if(TFR_UNDOPC) // Undefined Opcode
{
// USER CODE BEGIN (UNDOPCTrap,1)
BiosFatal(FATAL_ERR_CLASS_B_TRAP_UNDEFINED_OPCODE);
// USER CODE END

TFR_UNDOPC = 0;

// USER CODE BEGIN (UNDOPCTrap,2)
// USER CODE END
} // end of if Undefined Opcode

if(TFR_ACER) // Program Memory Interface Access Error
{
// USER CODE BEGIN (ACERTrap,1)
BiosFatal(FATAL_ERR_CLASS_B_TRAP_PROGRAM_MEM_INTERFACE_ACCESS);
// USER CODE END

TFR_ACER = 0;

// USER CODE BEGIN (ACERTrap,2)
// USER CODE END
} // end of if Programm Memory Interface Access Error

if(TFR_PRTFLT) // Protection Fault
{
// USER CODE BEGIN (PRTFLTTrap,1)
BiosFatal(FATAL_ERR_CLASS_B_TRAP_PROTECTION_FAULT);
// USER CODE END

TFR_PRTFLT = 0;

// USER CODE BEGIN (PRTFLTTrap,2)
// USER CODE END
} // end of if Protection Fault

if(TFR_ILLOPA) // Illegal Word Operand Access
{
// USER CODE BEGIN (ILLOPATrap,1)
BiosFatal(FATAL_ERR_CLASS_B_TRAP_ILLEGAL_WORD_OPERAND_ACCESS);
// USER CODE END

TFR_ILLOPA = 0;

// USER CODE BEGIN (ILLOPATrap,2)
// USER CODE END
} // end of if Illegal Word Operand Access

// USER CODE BEGIN (ClassBTrap,3)
// USER CODE END

} // End of function INT_viClassBTrap
0 Likes
0 Replies