Hello NFC community: NXP released the new PN7150 NFC Controller chip with enhanced power output, and there is also the new Arduino compatible demokit OM5578/PN7150ARD. See more information in the next pages: PN7150: High performance full NFC Forum-compliant controlle|NXP OM5578/PN7150ARD: Demoboards for PN7150|NXP There is also a new PN7120 SBC kit for arduino: http://cache.nxp.com/documents/user_manual/UM11008.pdf http://cache.nxp.com/documents/user_manual/UM11008.pdf Due to the Arduino interface pinout, these kits can also be used with Kinetis Freedom Boards. The target of this document is to create projects to use the NFC Controller lîbrary with the PN7120 or PN7150 together with a Kinetis host. Also you will find example projects created for the FRDM-K64F and FRDM-KL43Z. Requirements: - Kinetis Software Development Kit v1.3. -> Software Development Kit for Kinetis MCUs|NXP - KDS v3.x with KSDK v1.3 Eclipse Update Installed -> Kinetis Design Studio Integrated Development Enviro|NXP - Kinetis SDK project generator. Available from the "Downloads" tab of KSDK webpage -> Software Development Kit for Kinetis MCUs|NXP CREATING NEW PROJECT NOTE: In this step-by-step procedure the FRDM-K64F is used as reference. You can follow the guide according to your own Freedom board. 1) Open the KSDK project generator. 2) Enter the KSDK v1.3 installation path, give a name to the project, select your Freedom board and click on "Advanced": 3) In the advanced settings window enable the checkboxes for: - Include BSP files - Generate standalone project - Kinetis Design Studio toolchain - Board (confirm that your board is shown in the drop-down menu) NOTE: The path for the newly created project is set by default inside of the KSDK v1.3 installation. For a standalone project you can change the location, just remember such path to import the project to KDS workspace in a later step. Leave the rest of configurations as default (New project, Platform library, no RTOS) and finally click on "Advanced Generate!". 4) From Kinetis Design Studio go to File -> Import. 5) Go to General -> Existing Projects into workspace and click "Next". 6) In "select root directory" browse to the location of the platform lib for the created project. By default this path would be: C:\nxp\KSDK_1.3.0\examples\frdmk64f\user_apps\<project_name>\lib\ksdk_platform_lib\kds\<MCU> <project_name>: The name given initially to the project. <MCU>: The corresponding device number (K64F12 in this case). Make sure that the project check box is enabled and click on "Finish". 7) Select the KSDK platform library project and click on the "Hammer icon" to build it. 😎 Repeat steps 4 through 6, but this time browse to the location of the application project. In this example the path is: C:\nxp\KSDK_1.3.0\examples\frdmk64f\user_apps\< project_name >\kds INTEGRATING NFC CONTROLLER LIBRARY The next steps describe how to integrate the NFC NCI library to your newly created project. - The Arduino Interface Boards use the next pinout for communication between the OM5578/PN7150 or OM5577/PN7120 kits with the Freedom or Arduino boards: As shown in the picture, the pinouts are similar except for the 5V connection. This leverages the enhanced output power feature of the PN7150 NFC Controller. - We need to check the corresponding pins that will be used from the Freedom board. In this case, the connections to the FRDM-K64F board would be as next: IMPORTANT: The pinout shown below corresponds to Rev E3 schematics of FRDM-K64F. For Rev D1 the pin used for IRQ (header location J2[2]) must be PTA0 instead of PTC12. 1) Open the file gpio_pins.c and add 2 pin configurations: 1 input pin called NFCCirqPin and 1 output pin called NFCCvenPin. gpio_input_pin_user_config_t NFCCirqPin =
{
.pinName = kGpioNFCCirq,
.config.isPullEnable = false,
.config.pullSelect = kPortPullUp,
.config.isPassiveFilterEnabled = false,
.config.interrupt = kPortIntDisabled,
};
gpio_output_pin_user_config_t NFCCvenPin =
{
.pinName = kGpioNFCCven,
.config.outputLogic = 1,
.config.slewRate = kPortSlowSlewRate,
.config.driveStrength = kPortLowDriveStrength,
}; 2) In the file gpio_pins.h add 2 extra elements to the gpio enumeration. Also add extern declarations for the 2 pins defined in the previous step. NOTE: For FRDM-K64F the pins are PTC12 and PTC3. Select corresponding pins for your Freedom board. extern gpio_input_pin_user_config_t NFCCirqPin;
extern gpio_output_pin_user_config_t NFCCvenPin;
/*! @brief Pin names */
enum _gpio_pins_pinNames
{
kGpioSW2 = GPIO_MAKE_PIN(GPIOC_IDX, 6U),
kGpioSW3 = GPIO_MAKE_PIN(GPIOA_IDX, 4U),
kGpioSdhc0Cd = GPIO_MAKE_PIN(GPIOE_IDX, 6U),
kGpioLED1 = GPIO_MAKE_PIN(GPIOE_IDX, 26U),
kGpioLED2 = GPIO_MAKE_PIN(GPIOB_IDX, 22U),
kGpioLED3 = GPIO_MAKE_PIN(GPIOB_IDX, 21U),
kGpioNFCCirq = GPIO_MAKE_PIN(GPIOC_IDX, 12), /* GPIO for NFCC IRQ pin */
kGpioNFCCven = GPIO_MAKE_PIN(GPIOC_IDX, 3), /* GPIO for NFCC VEN pin */
} 3) In the file pin_mux.c define a function to configure the MUX setting of the required GPIO and I2C pins to interface with the NFC Controller. void configure_nfcc_pins(void)
{
/** I2C_SDA **/
PORT_HAL_SetMuxMode(PORTE,25u,kPortMuxAlt5);
PORT_HAL_SetOpenDrainCmd(PORTE,25u,true);
/** I2C_SCL **/
PORT_HAL_SetMuxMode(PORTE,24u,kPortMuxAlt5);
PORT_HAL_SetOpenDrainCmd(PORTE,24u,true);
/* NFCC IRQ */
PORT_HAL_SetMuxMode(PORTC,12u,kPortMuxAsGpio);
/* NFCC VEN */
PORT_HAL_SetMuxMode(PORTC,3u,kPortMuxAsGpio);
} NOTES: - Check the corresponding pins on your Freedom board. FRDM-K64F uses PTC12/PTC3 as GPIOs while PTE24/PTE25 are configured as I2C pins. For I2C pins also check the MUX number in the device's Reference Manual (e.g. PTE24/PTE25 in K64F have the I2C function in ALT5). - This function needs to be called from your project to configure the required pins. e.g. from hardware_init(). - Some Freedom boards share the I2C pins of the Arduino compatible header with an on-board I2C device (e.g. accelerometer), with SDA/SCL pull-up resistors populated already. If this is not the case for your board, make sure to place external pull-ups to MCU VDD or enable the internal pull-ups as temporary workaround. 4) Add the prototype of the function to the header file pin_mux.h. /*
** ===================================================
** Method : configure_nfcc_pins
*/
/*!
** @brief
** Set mux configuration for I2C and GPIO pins
** to interface with the NFC Controller.
*/
/* ==================================================*/
void configure_nfcc_pins(void); 5) Copy the folders NfcLibrary and TML to the project folder. The file fsl_i2c_irq.c is also required. In this case the file is found in the next path: C:\nxp\KSDK_1.3.0\examples\frdmk64f\user_apps\<project_name>\platform\drivers\src\i2c NOTE: If the project was not created in standalone mode, just search the fsl_i2c_irq.c file from your KSDK installation. 6) Add the NfcLibrary and TML folders with all its subfolders and files to the project's tree, so the lilbrary is part of the build. Also add the file fsl_i2c_irq.c to the project. In KDS you can drag and drop folders and files to the project explorer view. 7) Add the compiler include paths for the inc folders. 😎 From the KDS preprocessor settings add or remove the next conditional compilation macros according to your functional requirements: CARDEMU_SUPPORT: The NFC Controler host (MCU) can emulate a contactless card which can be accessed by an external Reader/Writer. P2P_SUPPORT: The host MCU can establish a 2-way communication accesing to or sending data to an external Reader/Writer. RW_SUPPORT: With this mode the host can access a remote contactless tag/card via the NFC Controller. NCI-DEBUG: If defined, all information transferred between the host MCU and the NFC Controller Interface (commands, responses, notifications, data) is echoed to console for debug purposes. 9) The file tml.h includes the macro NFCC_I2C_INSTANCE which defines the I2C module to use. For FRDM-K64F the module is I2C0. Set this macro according to your Freedom board. /* NFC Controller I2C interface configuration */
#define NFCC_I2C_INSTANCE 0 At this point the project is ready to use the NFC Controller library and interface the Kinetis Freedom board with PN7120 or PN7150 NFC Controllers. DEMO PROJECTS At the end of this document you will find 2 example project packages for the FRDM-K64F and FRDM-KL43Z. Both of the projects can be used with either the OM5578/PN7150 or OM5577/PN7120 kits using the Arduino interface boards. Each ZIP package includes 2 projects (example application and KSDK library). Unzip the package and import the projects from the resulting location. Do not select "Copy projects into workspace" in KDS. If you do so the build will fail due to the linked source files not copied over. The projects must be built in the next order: 1- Platform library project (FRDM-xxx_NFCNCI_Example\lib\ksdk_platform_lib\kds\<MCU>) 2- Demo project (FRDM-xxx_NFCNCI_Example\kds) The OpenSDA virtual COM port is used to send data to a terminal at 115200 baud. Below an explanation on how to test the different project example features. RW mode: - Placing a tag with a single text, URI or vCard NDEF record next to the NFC reader antenna. Examples: P2P mode: - Bring an android phone with NFC enabled close to the NFC controller antenna and use the "beaming" feature. In the case below the NXP home page is "beamed" from the adroid phone's explorer. After this, the NFC enabled phone will receive the "Test" NDEF record. CARD EMULATION mode For this mode it is required to remove the P2P_SUPPORT macro and rebuild/reprogram the project. - Bringing an android phone set to read a NFC tag close to the NFC controller board. The NFC enabled phone will detecta T4T tag type with the "Test" NDEF record. I hope you can find this document useful. Any questions or doubts please let me know in the comments. Jorge Gonzalez NXP Technical Support
View full article