hello,
I am trying to track down why and how these two applications are related. When I don't include the timer example, then my ndk runs fine. When I run the test function, the ndk will stop working and responding to network messages.
Versions: C6678, bios_6_32_05_54, ndk_2_200_05_17, pdk_C6678_1_0_0_17
Please help me to understand how these two are related.
Also, when I run the function, the value of timerISRCounter is always 2, another mystery.
Thanks!
Brandy
Here is the call from CORE_0
test_gp_timer(CSL_TMR_0);
Here is the timer_test function I am using (I integrated the init functions and the test function together as one call.):
static void TimerInterruptHandler (void *arg)
{
/* Increment the number of interrupts detected. */
timerISRCounter++;
/* Clear the event ID. */
CSL_intcEventClear((CSL_IntcEventId)arg);
}
static Int32 intc_init (void)
{
CSL_IntcGlobalEnableState state;
/* INTC module initialization */
context.eventhandlerRecord = EventHandler;
context.numEvtEntries = 10;
if (CSL_intcInit(&context) != CSL_SOK)
return -1;
/* Enable NMIs */
if (CSL_intcGlobalNmiEnable() != CSL_SOK)
return -1;
/* Enable global interrupts */
if (CSL_intcGlobalEnable(&state) != CSL_SOK)
return -1;
/* INTC has been initialized successfully. */
return 0;
}
Int32 test_gp_timer (Uint8 IntcInstance)
{
CSL_IntcHandle tmrIntcHandle;
CSL_TmrHandle hTmr;
CSL_TmrObj TmrObj;
CSL_IntcEventHandlerRecord EventRecord;
CSL_IntcParam vectId;
CSL_Status status;
CSL_TmrHwSetup hwSetup = CSL_TMR_HWSETUP_DEFAULTS;
CSL_TmrEnamode TimeCountMode = CSL_TMR_ENAMODE_ENABLE;//CSL_TMR_ENAMODE_CONT
Uint32 delayCount;
LOG_DEBUG ("**************************************************");
LOG_DEBUG ("****************** Timer Testing ****************");
LOG_DEBUG ("**************************************************");
/* Initialize the INTC Module. */
if (intc_init() < 0)
{
LOG_ERROR ("Error: Initialization of the INTC module failed.");
return;
}
/* Initialize timer CSL module */
CSL_tmrInit(NULL);
/* Clear local data structures */
memset(&TmrObj, 0, sizeof(CSL_TmrObj));
LOG_DEBUG("Testing 64bit Timer in Single Shot Mode...");
/**************************************************************
********************** INTC related code *********************
**************************************************************/
/* Open INTC */
vectId = CSL_INTC_VECTID_12;
tmrIntcHandle = CSL_intcOpen(&tmrIntcObj, CSL_GEM_TINTLN, &vectId, NULL);
/* Bind ISR to Interrupt */
EventRecord.handler = (CSL_IntcEventHandler)&TimerInterruptHandler;
EventRecord.arg = (void *)CSL_GEM_TINTLN;
CSL_intcPlugEventHandler(tmrIntcHandle, &EventRecord);
/* Event Enable */
CSL_intcHwControl(tmrIntcHandle, CSL_INTC_CMD_EVTENABLE, NULL);
/**************************************************************
********************** Timer related code ********************
**************************************************************/
/* Open the timer. */
hTmr = CSL_tmrOpen(&TmrObj, IntcInstance, NULL, &status);
if (hTmr == NULL)
return -1;
/* Set the timer mode to 64bit GP Timer Mode and set the PRD registers */
hwSetup.tmrTimerMode = CSL_TMR_TIMMODE_GPT;
hwSetup.tmrTimerPeriodLo = 0x0f;
hwSetup.tmrTimerPeriodHi = 0x00;
CSL_tmrHwSetup(hTmr, &hwSetup);
/* Reset the timer ISR Counter. */
timerISRCounter = 0;
/* Reset the Timer */
CSL_tmrHwControl(hTmr, CSL_TMR_CMD_RESET64, NULL);
/* Start the timer in SINGLE SHOT Mode. */
CSL_tmrHwControl(hTmr, CSL_TMR_CMD_START64, (void *)&TimeCountMode);
LOG_DEBUG("Waiting for Timer.");
/* INTC related code */
while (timerISRCounter < 1 );
LOG_DEBUG("Got Timer, value %i", timerISRCounter);
/* Good. The timer ISR was invoked; now we wait for some time and make
* sure that the ISR was not invoked again since this is a ONE SHOT
* Timer. */
for (delayCount = 0; delayCount < MAX_DELAY; delayCount++);
LOG_DEBUG("Got Timer, value %i", timerISRCounter);
/* Timer ISR Counter should still be the same */
// if (timerISRCounter != 1)
// return -1;
/**************************************************************/
/* Disable the interrupts. */
CSL_intcHwControl(tmrIntcHandle, CSL_INTC_CMD_EVTDISABLE, NULL);
/* Stop the Timer */
CSL_tmrHwControl(hTmr, CSL_TMR_CMD_RESET64, NULL);
/* Close the Tmr and interrupt handles */
CSL_tmrClose(hTmr);
CSL_intcClose(tmrIntcHandle);
LOG_DEBUG("Got Timer, value %i", timerISRCounter);
LOG_DEBUG("No Timer Errors.");
/* Test has been completed successfully. */
return 0;
}