User guide

CIF Peripheral Model - SimpleTimer
122 CoMET Version 5.9 – Tutorial
tWord32 interruptsReceived = 0;
int main(void)
{
printf("Testing the SimpleTimer\n");
varm_enable_interrupts(); // enable the ARM interrupts
enableMtr((tInt8) MTR_1); /* enable the Timer Match Timer 1 Register
and Interrupt */
setSimpleTimerMtr((tWord32) MATCH_TEST_VALUE, (tInt8) MTR_1); /* set
the value of the Match Timer */
while (interruptsReceived < MAX_INTERRUPTS){
int i;
for (i = 0;i < MAX_LOOPS;i++){
}
}
TspiVpmStop();
}
/* define any additional handlers required for your specific VPM */
/*****************************************************/
/* IRQ & FIQ handlers called from crt0
/*****************************************************/
void irq_handler(void)
{
tWord32 gtrValue = 0;
tWord32 result = 0;
gtrValue = getSimpleTimerTime();
deAssertInterrupt((tInt8) MTR_1); // Turn off the Match Timer 1
Interrupt
setSimpleTimerTime(0);
interruptsReceived++;
printf("Interrupt %d handled at GTR value
%#0x.\n",interruptsReceived, gtrValue);
}
void fiq_handler(void)
{
}
/*****************************************************/
/* Helper functions
/*****************************************************/
void setSimpleTimerTime(tWord32 time){
tWord32 *gtrPtr = (tWord32 *) GTR_PTR;
*gtrPtr = time;
}
tWord32 getSimpleTimerTime(){
tWord32 *gtrPtr = (tWord32 *) GTR_PTR;
return *gtrPtr;
}
void setSimpleTimerMtr(tWord32 time, tInt8 mtrId){
tWord32 *mtr1Ptr = (tWord32 *) MTR1_PTR;
tWord32 *mtr2Ptr = (tWord32 *) MTR2_PTR;
switch (mtrId) {