Hi @haihoang ,
The issue is
in the phDriver_LPCOpen.c . You are calling phDriver_TimerStop() function in the phDriver_TimerStart(). So the timer is not working for the NFC reader library. Please remove it and add the CTIMER_StopTimer(PH_DRIVER_LPC_TIMER) in the phDriver_TimerStop (void) function.
phStatus_t phDriver_TimerStart(phDriver_Timer_Unit_t eTimerUnit, uint32_t dwTimePeriod, pphDriver_TimerCallBck_t pTimerCallBack)
{
ctimer_match_config_t matchConfig0;
ctimer_config_t config;
uint64_t qwTimerCnt;
uint32_t dwPrescale;
uint32_t dwTimerFreq;
CLOCK_AttachClk(kFRO_HF_to_CTIMER0);
dwTimerFreq = CLOCK_GetFreq(kCLOCK_FroHf);
/* Timer count = (delay * freq)/Units. */
qwTimerCnt = dwTimerFreq;
qwTimerCnt = (qwTimerCnt / eTimerUnit);
qwTimerCnt = (dwTimePeriod * qwTimerCnt);
if(qwTimerCnt > (uint64_t)LPC_TIMER_MAX_32BIT_W_PRE)
{
return PH_DRIVER_ERROR | PH_COMP_DRIVER;
}
if(pTimerCallBack == NULL)
{ /* Timer Start is blocking call. */
dwTimerExp = 0;
pTimerIsrCallBack = phDriver_TimerIsrCallBack;
}else { /* Call the Timer callback. */
pTimerIsrCallBack = pTimerCallBack;
}
CTIMER_GetDefaultConfig(&config);
/* 32-bit timers, check prescale is required. */
if(qwTimerCnt > (uint64_t)LPC_TIMER_MAX_32BIT)
{
/* prescale is required. */
for(dwPrescale=2;(dwPrescale<=LPC_TIMER_MAX_32BIT)&&((qwTimerCnt/dwPrescale)>LPC_TIMER_MAX_32BIT);
dwPrescale++);
qwTimerCnt /= dwPrescale;
/* Setup 16-bit prescale value to extend range */
config.prescale=dwPrescale;
//Chip_TIMER_PrescaleSet(PH_DRIVER_LPC_TIMER, dwPrescale);
}
/* Initialize 16-bit timer 0 clock */
CTIMER_Init(PH_DRIVER_LPC_TIMER, &config);
/* Resets the timer terminal and prescale counts to 0 */
CTIMER_Reset(PH_DRIVER_LPC_TIMER);
/* Configuration */
matchConfig0.enableCounterReset = false;
matchConfig0.enableCounterStop = true;
matchConfig0.matchValue = qwTimerCnt;
matchConfig0.outControl = kCTIMER_Output_Toggle;
matchConfig0.outPinInitState = false;
matchConfig0.enableInterrupt = true;
CTIMER_RegisterCallBack(PH_DRIVER_LPC_TIMER, &ctimer_callback_table[0], kCTIMER_SingleCallback);
CTIMER_SetupMatch(PH_DRIVER_LPC_TIMER, PH_DRIVER_LPC_TIMER_MATCH_REGISTER, &matchConfig0);
/* Start timer */
CTIMER_StartTimer(PH_DRIVER_LPC_TIMER);
if(pTimerCallBack == NULL)
{
/* Block until timer expires. */
while(!dwTimerExp);
}
return PH_DRIVER_SUCCESS;
}
phStatus_t phDriver_TimerStop(void)
{
CTIMER_StopTimer(PH_DRIVER_LPC_TIMER);
CTIMER_DisableInterrupts(PH_DRIVER_LPC_TIMER, kCTIMER_Match1InterruptEnable);
CTIMER_Deinit(PH_DRIVER_LPC_TIMER);
/* Disable timer interrupt */
NVIC_DisableIRQ(PH_DRIVER_LPC_TIMER_IRQ);
return PH_DRIVER_SUCCESS;
}