User guide

CIF Peripheral Model - SimpleTimer
CoMET Version 5.9 – Tutorial 109
case StdLogicH:
/*
** Deassert all outputs.
*/
IP->InReset = TRUE;
AmpiLogicWrite(IP->MatchInterrupt[MATCH1_IX], StdLogicL);
AmpiLogicWrite(IP->MatchInterrupt[MATCH2_IX], StdLogicL);
// Cancel all "match" callbacks.
AmpiTaskScheduleCallbackCancel(IP->MatchEvent[MATCH1_IX]);
AmpiTaskScheduleCallbackCancel(IP->MatchEvent[MATCH2_IX]);
// Cancel all "unmatch" callbacks.
AmpiTaskScheduleCallbackCancel(IP->UnmatchEvent[MATCH1_IX]);
AmpiTaskScheduleCallbackCancel(IP->UnmatchEvent[MATCH2_IX]);
break;
CODE ENDS
When Reset ends, we set the registers to their default states. Modify the section case
StdLogicL to the following:
CODE BEGINS
case StdLogicL:
if (IP->InReset)
{
/*
** Leaving reset.
*/
IP->InReset = FALSE;
/*
** Perform Reset Functions to Registers etc.
*/
// Reset all the registers.
IP->regGTR = 0;
IP->regTER = 0;
IP->regTIER = 0;
IP->regTIFR = 0;
IP->regMTR[MATCH1_IX] = 0;
IP->regMTR[MATCH2_IX] = 0;
}
break;
CODE ENDS
Because we changed the value of the counter we need to save the current time for later
calculation of the counter value. Add the following immediately before the end brace of the
Reset function
IP->LastCounterUpdateTime = AmpiClockGetTicks(IP->TimerClock, 0);
Modifying the ReadRegister Function - Respond to Register Reads
The ReadRegister function begins with a comment and statement similar to the following:
/**
** Function:
** tWord32 ReadRegister(
** tInstanceData *IP, const tWord32 Address, tBoolean Untimed)
**