Configuring PN512 correctly

Forum / MIFARE and NFC Reader IC`s / Configuring PN512 correctly

Tagged: , ,

  • 20. August 2015 at 18:09
    Hi all,

    I am working with a PN512 (HVQFN40). The system is fully functional, and the self test on the chip is passed successfully. All I need is to be able to configure the chip correctly to:

    1. as the first step, be able to act as an initiator (I hope this is a correct assumption) and read the NFCID for each card which is close enough to the antenna;
    2. and then as the second step, I would like to be able to run different ADPUs.

    As far as I know, in order to be able to detect NFCID of a card, it is not important to set the protocol which will become important as soon as the ID is extracted and ADPUs are intended to be run on the card.

    Now I would like to know where can I find information or guideline about minimum configuration that will make the PN512 chip functional. At the moment, I try to enable the chip by setting following registers:

    PN512_write_reg(ControlRegAddr, 0x10);
    PN512_write_reg(ModeRegAddr, 0x3b);
    PN512_write_reg(TxControlRegAddr, 0x3);
    PN512_write_reg(TxAutoRegAddr, 0x3);
    while ((PN512_read_reg(ControlRegAddr) & 0x20) == 0x0);

    But the loop becomes infinite and the bit for NFCID which is set when the ID is located in FIFO is never set. Can anybody help with correct configuration or let me know if there is any example for such configuration available? I have checked the software library shipped with PN512 but I couldn't extract useful data because of used HAL that will abstract everything away. I would appreciate any help.



    + 0  |  - 0

    Re: Configuring PN512 correctly

    30. March 2016 at 9:33
    Hi Dan,

    I do not know whether your issue has been solved in the meantime. But I can offer command sequences for PN512. This sequences gives you byte values which register has to be initialized for different purposes.

    If you still interested, please contact me at:

    Kind regards,
    The MIFARE Team

    + 2  |  - 0

    Re: Configuring PN512 correctly

    29. June 2016 at 12:16
    Hi mifaressdk

    I am experiencing the same issue as Dan. I am able to communicate with the PN512 chip and can send the configure sequence and perform a self-test. I am unable to proceed further than that and get the PN512 into a mode that will detect cards.

    Can you also please send me a copy of the command sequence to correctly setup and put the PN512 into a mode that allows it to detect cards. My email address is

    Thanks in advance.
    Shaheen Mahomed
    + 0  |  - 0

    Re: Configuring PN512 correctly

    1. August 2016 at 16:48
    Hi all,

    I'm actually working on the PN512 and have issues while doing the self test.

    The sequence I have doesn't match with the one mentionned in the datasheet.

    Expected sequence : 00h, EBh, 66h, BAh, 57h, BFh, 23h, 95h, D0h, E3h, 0Dh, 3Dh, 27h, 89h, 5Ch, DEh,
    9Dh, 3Bh, A7h, 00h, 21h, 5Bh, 89h, 82h, 51h, 3Ah, EBh, 02h, 0Ch, A5h, 00h,
    49h, 7Ch, 84h, 4Dh, B3h, CCh, D2h, 1Bh, 81h, 5Dh, 48h, 76h, D5h, 71h, 61h,
    21h, A9h, 86h, 96h, 83h, 38h, CFh, 9Dh, 5Bh, 6Dh, DCh, 15h, BAh, 3Eh, 7Dh,
    95h, 3Bh, 2Fh

    The sequence I have : 0x00 0xBE 0x88 0x7A 0x99 0xAE 0xE1 0xAE 0x42 0x28 0xBA 0xDC 0xEB 0xBC 0x63 0x0B 0xB7 0xFF 0xC6 0xBF 0x10 0xE3 0x2F 0x9C 0xDB 0x5D 0xED
    0x3D 0x3C 0xA4 0x6E 0x72 0xE3 0xF7 0xE8 0xB9 0x6A 0xAC 0xC9 0x58 0xD2 0x90 0xE5 0xAC 0x42 0x82 0xB2 0x2E 0x78 0xCD 0xCE 0x10 0x4D 0xE8
    0xFB 0x99 0x2D 0x62 0x65 0x7B 0x82 0xC7 0x57 0x29

    Am I the only one facing this issue ?

    Were you also able to detect NFC tags ? If yes, would you share the sequence you used ?

    Thanks in advance,
    Best regards,
    Benjamin OLIVIER
    + 0  |  - 0

    Re: Configuring PN512 correctly

    4. August 2016 at 14:09
    Hi Benjamin,

    The self-test is used in the factory as part of the test procedure. Please take in mind that the self-test result depends on the version. See chapter 20 Errata in the data sheet for the differences of self-test outputs.

    The MIFARE Team

    + 0  |  - 0

    Re: Configuring PN512 correctly

    5. August 2016 at 19:35

    Thank you very much for your answer.

    I actually identified the issue for the self-test problem. The thing is I didn't turn the analog receiver part on (in the Command Register, bit 6 = 0).

    So far I'm able to read the self test answer successfully.

    My next step is to be able to detect a NFC tag ID.

    I'm actually doing the following sequence,

    Soft reset
    (CommandReg = 0x0F)
    FIFO write :
    0x04, 0x00 (SENS_RES)
    0xA1, 0xA2, 0xA3 (also tried with 0x08 0xA2 0xA3) (NFCID1)
    0x40 (SEL_RES)
    0x01, 0xFE, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0x23, 0x45 (polling response)
    Config Command
    (CommandReg = 0x01)
    AutoColl Command
    (CommandReg = 0x0D)

    The configuration sequence comes from the NFC reader library. Unfortunately I wasn't able to port it to my project yet (running on IAR, working on a KW21D512 chip).

    As my final goal is to read the tag ID only, as initiator and passive communication, would you have a sequence to help me ?

    Thanks in advance for your help,
    Best regards,
    Benjamin OLIVIER

    + 0  |  - 0

    Re: Configuring PN512 correctly

    11. August 2016 at 20:35

    I got same problem here with NXP PN5120 which is currently working perfectly with LPC1769.
    when running with NfcrdlibEx4_MIFAREClassic and NfcrdlibEx1_BasicDiscoveryLoop.

    However, when integrate the PN5120 with Nucleo STM32 F030R8. I could not read the tags, the DiscLoop_run method always return NoTechDetected (refer the Poll_Mode in Discovery Loop).
    I have no clue what is going on and how to solve the problem.
    Anyone has any idea?

    The code has been ported from NfcrdlibEx4_MIFAREClassic example with follow steps:

    • Disable macro RTOS & PH_PlATFORM

    • Compile the ReaderLib with SW4STM32 IDE.

    • Base on STM sample project & SW4STM32 IDE, link to the ReaderLib.

    • Port NfcrdlibEx4_MIFAREClassic.c, all the flow for Rc523 are retained, remove others HAL e.g 663, 5180

    • Implement my own STM32 phbalReg, especially the Exchange method.

    The SW run perfectly, the sequense commands are same with NXP sample.

    • PN512 version return successful (0x82) when sending 0xEE (address 0x37h) 0

    • TxControlReg return 0x80 which are same as Datasheet.

    • However, tag can't be detected

    Other question
    Do we really need SetInterupt() function in NfcrdlibEx4_MIFAREClassic.c, I remmove the method and tags still can be detected using the LPC1769?

    + 0  |  - 0

    Re: Configuring PN512 correctly

    12. August 2016 at 9:11
    Hi Justin,

    You refer to the NxpRdLib, right?

    The team here are not the developers of the library, sorry.

    The MIFARE Team

    + 0  |  - 0

    Re: Configuring PN512 correctly

    24. August 2016 at 11:07
    Justin Nguyen,
    I have the same problem... I am using the library in a STM host MCU, it works well but it can not detect any tag... did you find any solution to this issue?

    + 0  |  - 0

    Re: Configuring PN512 correctly

    7. September 2016 at 19:19
    Yes, STM spi driver reject null rxbuffer, but reader library pass null when flush fifo. Hence, the request is not sent and disloop flow is broken.
    + 0  |  - 0

    Re: Configuring PN512 correctly

    8. September 2016 at 8:32

    Thank you for your response. Interesting point...

    How do you solve it? could you tell me please? do you meant that you need to send something when you fluh the FIFO? please tell me I am very interested in it.


    + 0  |  - 0

    Re: Configuring PN512 correctly

    27. September 2016 at 8:04
    Hello MIFARESDK,

    I have been able to port the NXP NFC Rd Lib to our MCU. So far, everythiong seems to work smoothly with some basic and simple code examples. Now I am trying to understand the whole process of initialization. Would you be so kind of leting me know those command sequences for PN512 that you are offering.

    I would appreciate so much.

    Diego Valladolid.
    + 0  |  - 0

    Re: Configuring PN512 correctly

    30. September 2016 at 9:25
    Hi Diego,

    I you want to understand the whole process of initialization, you have to go into the details of NFC communication, including to understand the protocol specifications ISO14443 part 1 to 4. With these knowledge and the whole capabilities of the PN512 you are able to implement any use-case and any NFC product.

    But how do you bring this approach to the lot of different requirements and lot of different programming languages and operating systems?

    The NxpRdLib will help you with your software project. But you are free to optimize your project with your own ideas. I recommend to go through the code and extract what you need. Keep in mind, the NxpRdLib is written for a lot of reader chips and use-cases you will never need nor use.

    The TapLinx Team
    + 0  |  - 0

    Re: Configuring PN512 correctly

    23. January 2017 at 20:28
    Hi all,

    I need to use a Explore NFC borad with 16 bit Freescale controller to read a MIFARE ultralight EV1 card. I have configured SPI commmunicatioon using codewarrior IDE. I need to know how should I use the available Linux based library to read from the MIFARE card and give access control to another PCB controlled by the 16 bit freescale controller.

    A step by step instructions will be of great help,, as i am new to these things.

    Thanks in Advance
    + 0  |  - 0
Viewing 14 posts - 1 through 14 (of 14 total)

You must be logged in to reply to this topic.