Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: fixed related articles (broken due to not having an exclusive space anymore)

...

Panel
bgColor#fff
  1. Before connecting the NFC device to the host device please make sure that your SPI interface works in general by short-circuiting the MOSI and MISO and verifying with a basic SPI transceive operation if the data is echoed back correctly. Following python script can be used as an example (port it to the specific platform if the platform does not support Python 3):

    Code Block
    languagepy
    titleLoopback test
    #!/usr/bin/python
    
    import spidev
    spi = spidev.SpiDev()
    spi.open(0,0)
    spi.max_speed_hz = 1000000
    msg = [0xDE, 0xAD, 0xC0, 0xDE]
    result = spi.xfer2(msg)
    print (''.join('0x' + format(x, '02X') + ',' for x in result))

    The expected output when running this example is 0xDE,0xAD,0xC0,0xDE. Please note that this only confirms that your SPI interface is able to send and receive data but it does not check if SPI parameters such as clock phase and clock polarity are set correctly. Verifying that is also possible as shown in the next step.

  2. Connect the NFC device to the host device. Following SPI query is recommended for testing basic SPI communication with the NFC device.

    To execute that command a simple python script can be used (port it to the specific platform if the platform does not support Python 3):

    Code Block
    languagepy
    titleSPI MISO validation
    #!/usr/bin/python
    
    import spidev
    spi = spidev.SpiDev()
    spi.open(0,0)
    spi.max_speed_hz = 1000000
    spi.mode = 0 #CPOL=0,CPHA=0 - data sampled at rising edge
    msg = [0x30, 0xFF, 0xFF, 0xFF]
    result = spi.xfer2(msg)
    print (''.join('0x' + format(x, '02X') + ',' for x in result))

    The expected output when running this example is 0x00,0x00,0x00,0x21. Note that this confirms basic SPI functionality but still implementation-dependent bugs (e.g. byte alignment for DMA transfers, maximum buffer size limitations) or even hardware-related issues (e.g. bad ground, capacitive behaviour on data lines) can cause a SPI communication fail even if the basic SPI transaction shown in this example works. For correct operation of the NFC device also an interrupt signal is required, but usually validation of the reception of that signal can be done while implementing the SDK's HAL layer.

...

Content by Label
showLabelsfalse
max5
spacesWNFC
showSpacefalse
sortmodified
reversetrue
typepage
cqllabel in (= "spi" ,"sdk",and label = "nfc" ) and type = "page" and space = "WNFC"
labelsSPI SDK NFC


Page properties
hiddentrue


Related issues