-
本文介紹 E-lock 使用 NFC frontend IC “ PN5180 ”讀取卡片資訊的 software stack NFC Reader Library V5.22 及低功耗技術 LPCD 介紹與參數設定。
二. NFC Reader Library
- 1. NFC Reader Library initialization concept
The NFC Frontend PN5180 can be used with the NXP reader Library. The NXP reader library is written in C. This Library API is organized in independent layers which helps a lot software engineers to build up own NFC application starting from bottom physical layers (digital interfaces connection between MCU and NFC frontend) until upper Application layers.
The application requirements define which modules need to be enabled.
By default, the projects are preconfigured to be run on the PNEV5180B development board. This is defined by preprocessor directive PHDRIVER_LPC1769PN5180_BOARD (properties-> settings->preprocessor) and by macro in “../intfs/ph_NxpBuild_App.h”.
~\NfcrdlibEx1_BasicDiscoveryLoop\intfs\ph_NxpBuild_App.h |
# define NXPBUILD__PHHAL_HW_PN5180 |
Host interface initialization generates a data context used to initialize and configure the upper layer ( HAL )
~\NfcrdlibEx1_BasicDiscoveryLoop\NfcrdlibEx1_BasicDiscoveryLoop.c |
/******************************************************************************* ** Main Function *******************************************************************************/ int main (void) { … status = phbalReg_Init(&sBalParams, sizeof(phbalReg_Type_t)); |
~\NfcrdlibEx1_BasicDiscoveryLoop\NfcrdlibEx1_BasicDiscoveryLoop.c |
/******************************************************************************* ** Main Function *******************************************************************************/ int main (void) { … AppContext.pBalDataparams = &sBalParams; dwStatus = phNfcLib_SetContext(&AppContext); |
NFC Reader IC initialization generates a data context used to initialize PAL and Discovery Loop components
~\NfcrdlibEx1_BasicDiscoveryLoop\NfcrdlibEx1_BasicDiscoveryLoop.c |
/******************************************************************************* ** Main Function *******************************************************************************/ int main (void) { … /* Initialize library */ dwStatus = phNfcLib_Init(); |
~\NfcrdlibEx1_BasicDiscoveryLoop\NfcrdlibEx1_BasicDiscoveryLoop.c |
/******************************************************************************* ** Main Function *******************************************************************************/ int main (void) { … /* Set the generic pointer */ pHal = phNfcLib_GetDataParams(PH_COMP_HAL); pDiscLoop = phNfcLib_GetDataParams(PH_COMP_AC_DISCLOOP); |
三. LPCD ( Low Power Card Detection )
The contactless readers periodically activates the RF field to poll for the cards.
The LPCD reduces the average current consumption by providing a much shorter RF_ON interval for the card detection.
For Example 1 – Basic Discovery Loop, Low Power Card Detection ( LPCD ) is enabled in passive poll mode.
The low-power card detection ( LPCD ) is an energy saving configuration option for the PN5180.
LPCD parameter “Field On Time” defines the RF-ON time for the AGC measurement. The minimum RF-ON time depends on the antenna configuration and the connected matching network. It needs to be chosen in such a way that a stable condition for the AGC measurement is given at the end of the time.
For NXP NFC IC PN5180 :
EEPROM address |
0x36 |
Name |
LPCD_FIELD_ON_TIME |
Description |
Field On Time : Defines the ping length in multiple of 8µs + a fix time of 62µs. Example: 0x10 -> 16 x 8µs + 62 µs = 190µs |
LPCD parameter “Standby time”. This value defines the time between two pings in ms.
Field On Current: This value is the ITVDD under the loading condition, when RF field is on with the used gear. This value does not have any influence on the LPCD execution or performance as such, but simply is used to estimate the overall average current consumption. This current estimation is calculated, when the LPCD is started.
~\NxpNfcRdLib\intfs\phhalHw_Pn5180_Instr.h |
#define PHHAL_HW_CONFIG_SET_LPCD_WAKEUPTIME_MS 0x0070U /**< Used value for wakeup counter in msecs, i.e. after this amount of time IC will wakes up from standby. */ #define PHHAL_HW_CONFIG_LPCD_MODE 0x0071U /**< Used to set options PHHAL_HW_PN5180_LPCD_MODE_DEFAULT or PHHAL_HW_PN5180_LPCD_MODE_POWERDOWN */ |
圖 3.4 Stanby Time ≈ 5mS
Set PHHAL_HW_CONFIG_LPCD_MODE → PHHAL_HW_PN5180_LPCD_MODE_POWERDOWN and set the value of PHHAL_HW_CONFIG_SET_LPCD_WAKEUPTIME_MS for LPCD parameter “Standby time”.
~\NfcrdlibEx1_BasicDiscoveryLoop\src\phApp_Init.c |
wValue = PHHAL_HW_PN5180_LPCD_MODE_POWERDOWN; wConfig = PHHAL_HW_CONFIG_LPCD_MODE; status = phhalHw_Pn5180_Int_LPCD_SetConfig( pHal, wConfig, wValue );
|
wConfig = PHHAL_HW_CONFIG_SET_LPCD_WAKEUPTIME_MS; wValue = 300; status = phhalHw_Pn5180_Int_LPCD_SetConfig( pHal, wConfig, wValue ); |
NXP NFC Reader Library v05.22.00 Hardware Abstraction Layer » component : Pn5180 Instruction Functions :
§ phhalHw_Pn5180_Int_LPCD_SetConfig()Set config for LFCD which is IC specific. This function can be used to set configuration parameters of LPCD. |
LPCD parameter “Threshold Value” defines the AGC threshold value. This value is used to compare against the current AGC value during the lowpower card detection phase. if the difference between AGC reference value and current AGC value is greater than LPCD_THRESHOLD, the IC wakes up from LPCD.
For NXP NFC IC PN5180 :
EEPROM address |
0x37 |
Name |
LPCD_THRESHOLD |
Description |
Defines the threshold window. As soon as the AGC value during the LPCD ping exceeds the AGC reference value + threshold window, the IRQ will be raised and the PN5180 wakes up. |
-
- PN5180 Evaluation board quick start guide https://www.nxp.com/docs/en/application-note/AN11744.pdf
- DESIGN AND IMPLEMENT NFC APPLICATIONS SESSION 4: NFC READER LIBRARY SW SUPPORT FOR NFC FRONTENDS AND NFC CONTROLLERS WITH CUSTOMIZED FIRMWARE October 2016 https://www.themobileknowledge.com/wp-content/uploads/2017/05/NFC-Reader-Library.pdf
- NXP Community “PN5180 LPCD mode instructions”
https://community.nxp.com/t5/MCUXpresso-General/PN5180-LPCD-mode-instructions/m-p/858509 - PN5180 – The best full NFC frontend on the market January 2016 Product support package https://www.themobileknowledge.com/wp-content/uploads/2017/05/PN5180-Product-support-package.pdf
- CLRC663 plus - Push your NFC design further https://www.nxp.com/video/clrc663-iplus-i-push-your-nfc-design-further:CLRC663-CHARACTERISTICS-VID
- NFC Example Basic Discover Loop NoSheng Hsieh_2020.09.18.pdf
- NFC Example MIFARE Classic NoSheng Hsieh_2020.08.11.pdf
- PN5180 datasheet https://www.nxp.com/docs/en/data-sheet/PN5180.pdf
評論