NFC PN5190 with LPC55S16 IRQ issue

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

NFC PN5190 with LPC55S16 IRQ issue

Jump to solution
2,766 Views
haihoang
Contributor II

Hi expert,

    After run demo NfcrdlibEx1_DiscoveryLoop on PN5190EVB kit (use mk82 mcu) success, i ported the demo to LPC55S16EVK, but without successful,

    In phacDiscLoop_Run, after some interrupts from PN5190 and read/write via SPI, the MCU block on phOsal_Sleep, please take a look on the call stack and project file

Capture2.PNG   

    Please show me next step check to find out the problem ?

Many thanks,

HaiHoang

Labels (1)
0 Kudos
Reply
1 Solution
2,471 Views
LinnHT
NXP Employee
NXP Employee

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;
}

View solution in original post

8 Replies
2,472 Views
LinnHT
NXP Employee
NXP Employee

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;
}
2,425 Views
haihoang
Contributor II
Hi LinnHT,
I modified the code according to your suggestion and now it works
Thank you very much,
HaiHoang
0 Kudos
Reply
2,460 Views
haihoang
Contributor II

Hi @LinnHT 

    For LPCOpen source, i used from example (for LPC55S69):
https://community.nxp.com/t5/NFC-Knowledge-Base/Using-NFC-Reader-Library-with-LPC55S69/ta-p/1117479

and ported to LPC55S16

So, it seem there are some miss take on this, let me try and update the result

Many thanks,

HaiHoang

0 Kudos
Reply
2,708 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

I have checked the block diagram of NFC PN5190, it appears that PN5190 connection with LPC55S16EVK is just 4 wires SPI port and one interrupt pin, can you post the hardware connection and clarify your issue? Do you means that the spi port does not work or external  interrupt pin does not work?

I have LPC5516-EVK board but I do not have PN5190EVB kit.

 

BR

XiangJun Rong

0 Kudos
Reply
2,668 Views
haihoang
Contributor II

Hi XiangJun Rong,

    Thanks for your support

can you post the hardware connection and clarify your issue 

LPC55S16EVK connect SPI8 with PN5190EVB with 8 pin: MISO, MOSI, SCK, NSS, IRQ, VEN, +5V and GND,

You can see detail on attached project in my previous message

Do you means that the spi port does not work or external  interrupt pin does not work?

May be the external interrupt not work, because mcu call phApp_ConfigureLPCD successfull (please take a look on call stack in my previous message

I think there are some problem in NFC stack if work with cortex M33, any suggest for me in this case ?

Many thanks
HaiHoang

 

0 Kudos
Reply
2,637 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

I suppose that you use PINTx module to generate an interrupt, this is a snippet for PINTx module based on LPC5536, pls refer to it.

BTW, there is PINTx example in SDK package, pls refer to it.

You can download SDK package from the website:

https://mcuxpresso.nxp.com/en/welcome

 

Hope it can help you

BR

XiangJun Rong

 

//P0_13 Hall_sensor_A
//P0_14 Hall_sensor_B
//P1_11 Hall_snesor_C

void InitPINT(void)
{
//pin configuration:
//enable IOCON gated clock
//enable the IOCON gated clock
SYSCON->AHBCLKCTRL0|=1<<13;
IOCON->PIO[0][13] |=0x100;
IOCON->PIO[0][14] |=0x100;
IOCON->PIO[1][11] |=0x100;

//enable gated clock for GPIO0/GPIO1 for reading the GPIO pin logic


SYSCON->AHBCLKCTRLSET[0] |=1<<11;//enable INPUTMUX interface clock in SYSCON
SYSCON->AHBCLKCTRLSET[0] |=SYSCON_AHBCLKCTRL0_PINT_MASK;//enable PINT0 interface clock in SYSCON
SYSCON->PRESETCTRLSET[0] |=SYSCON_PRESETCTRL0_PINT_RST_MASK;
SYSCON->PRESETCTRLCLR[0] |=SYSCON_PRESETCTRL0_PINT_RST_MASK;

INPUTMUX->PINTSEL[0] =INPUTMUX_PINTSEL_INTPIN(0xD);//interrupt PINT0_0 from P0_13
INPUTMUX->PINTSEL[1] =INPUTMUX_PINTSEL_INTPIN(0xE);//interrupt PINT0_1 from P0_14
INPUTMUX->PINTSEL[2] =INPUTMUX_PINTSEL_INTPIN(0x2B);//interrupt PINT0_2 from P1_11

PINT->ISEL =0x00;//edge-sensitive interrupt
PINT->RISE |=PINT_RISE_RDET(0x07);//generate interrupt on rising edge
PINT->FALL |=PINT_FALL_FDET(0x07);//generate interrupt on falling edge
PINT->IST |=PINT_FALL_FDET(0x07);//clear rising edge and falling edge flag
PINT->SIENF |=PINT_IENF_ENAF(0x07);
PINT->SIENR |=PINT_IENF_ENAF(0x07);

EnableIRQ(PIN_INT0_IRQn);
EnableIRQ(PIN_INT1_IRQn);
EnableIRQ(PIN_INT2_IRQn);
}
//PIO0_13 pin generates interrupt
void PIN_INT0_IRQHandler(void)
{
/* period calculation between two HS_A edges */
uw16HSedge = 0x0000;
//uw16HSperiod = (uint16_t)MLIB_Sub_F16_FCi((uint16_t)uw16HSedge,(uint16_t)uw16HSedgeK_1);
uw16HSedgeK_1 = uw16HSedge;
/* define maximum period */
if(uw16HSperiod>32767)
uw16HSperiod = 32767;

commutationHS(f16DirectionOfRotation);
PINT->IST |= 0x00000001;//clear PINT0_0 flag
PINT->FALL |= 0x00000001;//clear PINT0_0 falling edge flag
PINT->RISE |= 0x00000001;//clear PINT0_0 rising edge flag
asm("nop");
temp=GPIO->PIN[0]; //GPIO_PortRead(GPIO, 0);
if(temp&(1<<13))
{
GPIO->SET[0]=1<<22;
}
else
{
GPIO->CLR[0]=1<<22;
}
M1_END_OF_ISR;
}

0 Kudos
Reply
2,603 Views
haihoang
Contributor II

Hi,

    It seems to be closely related to the communication between the MCU and the PN5190 according to the NFC stack, as I have seen it interrupt 15 times (meaning the pin interrupt setting was successful), but the 16th time from the PN5190 did not happen ( because the PN5190 does not pull this interrupt pin), possibly because the PN5190 has not been configured correctly

    In this state the MCU is waiting at __WFE, so there is no way for it to exit this command without an interrupt from PN5190.

    Do you have a NFCLIB port that works well with the cortex M33 series? Can I refer to it?

0 Kudos
Reply
2,546 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

I have LPC5516-EVK board, unfortunately, I have not NFC PN5190EVB kit, I am sorry, I can not have a test.

BR

XiangJun Rong