NTP5332 Read/Write I2C not working

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

NTP5332 Read/Write I2C not working

1,239 Views
mrab
Contributor I

I am using the OM2NTP5332 eval board to test whether I can power a sensor using the energy harvesting feature of the NTP5332. I have hooked it up to an Arduino Uno for testing. It acts as the I²C master for configuration, as well as the "sensor" slave. I have also written a tiny Android application for my test phone. 

The Arduino software configures the following using I²C:

  1. Unlocking all memory sectors by setting NFC_LOCK_0, NFC_LOCK_1, I2C_LOCK_0 and I2C_LOCK_1 to all 0s
  2. "Destroying" the Capability container by setting 0xAA55AA55 at location 0x0000
  3. Setting the configuration memory to 0x0892FF00 at location 0x1037. This, to my knowledge:
    • enables ARBITER_MODE regardless of energy harvesting state
    • sets the device to be in "I²C Master" mode
    • uses SRAM as volatile memory and enables it
    • Sets data transfer direction to go from I²C to NFC (sensor to NTP5332)
    • Enables "Extended commands"

Then, it goes into "slave mode" and awaits I²C read requests, emulating a sensor I want to read. The android application simply waits for an NFC tag to be discovered, checks for NFC 5 support and then sends custom commands using byte buffers. I have used SW5870 for reference. This, for the most part, works. However, I cannot get the READ I2C and WRITE I2C commands to work. 

I can read and write both SRAM and configuration memory using both I²C and NFC, so I know my hardware setup is sound. According to AN12368, all requirements for these two commands to work are fulfilled, judging from the readouts of the configuration memory. All I get on the android side is the response 0x010F, which, if I understand correctly, just signals there is an error and that the error code is 0x0F. This, in turn, is called an "unknown error" in the datasheet, which is not helpful at all. I can verify using an oscilloscope that the SDA and SCL lines don't even budge and remain high due to the external pullups.

I have tried many different configurations and combinations of configuration values, to no avail. I'd appreciate it if someone more familiar with this chip could help me out on this or give me a pointer.

Here's the byte buffers for both the READ and WRITE commands:

val write_i2c_cmd = ubyteArrayOf(
   0x12u, // flags
   0xD4u, // WRITE I2C constant
   0x04u, // manufacturer code
   0b00001000u, // I2C address
   0x00u, // N-1 bytes to write
   0x00u  // single, empty data byte
).toByteArray();

val read_i2c_to_sram_cmd = ubyteArrayOf(
   0x12u, // flags
   0xD5u, // READ I2C constant
   0x04u, // manufacturer code
   0b00001000u, // I2C address
   0x00u  // N-1 bytes to read
).toByteArray();


If more information is required, let me know.

0 Kudos
Reply
3 Replies

1,082 Views
EduardoZamora
NXP TechSupport
NXP TechSupport

Hello @mrab,

Happy New Year!

Hope you are doing well.

I truly apologize for the delay and the inconvenience this might have caused you.

When you mention that the device goes into "slave mode", does it mean that USE_CASE_CONF is set to 00b (I2C Slave)?

By any chance, is SW3 - 3 in ON position (3-4)? You can refer to NTAG 5 link and switch development board - Getting started guide, Table 4.

Please, consider that any change to the CONFIG register (or any other configuration register) will only be effective after a Power On Reset. If the NFC device sets USE_CASE_CONF to I2C Master and no POR is performed, the configuration will not be effective, and you may receive 0x010F as response.

Also, NTAG 5 must be the only I2C master acting device on the I2C-bus. Could you please confirm that this is the case?

 

1,025 Views
mrab
Contributor I
Hello @EduardoZamora,
Happy new Year to you too, and thanks for reaching out!

I can confirm the following:
- SW3-3 is OFF
- Slave mode is enabled (USE_CASE_CONF is set to 00b)
- Multiple PORs have been performed after configuration, the register value for USE_CASE_CONF has been loaded correctly
- The NTAG 5 is the only I2C master device

In the meantime, I have implemented my desired batch transfer using READ/WRITE SRAM commands and use the Event detection mode "I2C to NFC passthrough" to detect when my host can write new data. This works fine for now, but a "proper" solution would be nice, still.

0 Kudos
Reply

1,008 Views
EduardoZamora
NXP TechSupport
NXP TechSupport

Hi,

If you are using Energy Harvesting, please try with SW3 - 3 in ON position; also, USE_CASE_CONF should be set to 01b (I2C master) in order to use WRITE I2C and READ I2C commands.

Regards,
Eduardo.

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2256215%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ENTP5332%20Read%2FWrite%20I2C%20not%20working%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2256215%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI%20am%20using%20the%20OM2NTP5332%20eval%20board%20to%20test%20whether%20I%20can%20power%20a%20sensor%20using%20the%20energy%20harvesting%20feature%20of%20the%20NTP5332.%20I%20have%20hooked%20it%20up%20to%20an%20Arduino%20Uno%20for%20testing.%20It%20acts%20as%20the%20I%C2%B2C%20master%20for%20configuration%2C%20as%20well%20as%20the%20%22sensor%22%20slave.%20I%20have%20also%20written%20a%20tiny%20Android%20application%20for%20my%20test%20phone.%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20Arduino%20software%20configures%20the%20following%20using%20I%C2%B2C%3A%3C%2FP%3E%3COL%3E%3CLI%3EUnlocking%20all%20memory%20sectors%20by%20setting%20NFC_LOCK_0%2C%20NFC_LOCK_1%2C%20I2C_LOCK_0%20and%20I2C_LOCK_1%20to%20all%200s%3C%2FLI%3E%3CLI%3E%22Destroying%22%20the%20Capability%20container%20by%20setting%200xAA55AA55%20at%20location%200x0000%3C%2FLI%3E%3CLI%3ESetting%20the%20configuration%20memory%20to%200x0892FF00%20at%20location%200x1037.%20This%2C%20to%20my%20knowledge%3A%3CUL%3E%3CLI%3Eenables%20ARBITER_MODE%20regardless%20of%20energy%20harvesting%20state%3C%2FLI%3E%3CLI%3Esets%20the%20device%20to%20be%20in%20%22I%C2%B2C%20Master%22%20mode%3C%2FLI%3E%3CLI%3Euses%20SRAM%20as%20volatile%20memory%20and%20enables%20it%3C%2FLI%3E%3CLI%3ESets%20data%20transfer%20direction%20to%20go%20from%20I%C2%B2C%20to%20NFC%20(sensor%20to%20NTP5332)%3C%2FLI%3E%3CLI%3EEnables%20%22Extended%20commands%22%3C%2FLI%3E%3C%2FUL%3E%3C%2FLI%3E%3C%2FOL%3E%3CP%3EThen%2C%20it%20goes%20into%20%22slave%20mode%22%20and%20awaits%20I%C2%B2C%20read%20requests%2C%20emulating%20a%20sensor%20I%20want%20to%20read.%20The%20android%20application%20simply%20waits%20for%20an%20NFC%20tag%20to%20be%20discovered%2C%20checks%20for%20NFC%205%20support%20and%20then%20sends%20custom%20commands%20using%20byte%20buffers.%20I%20have%20used%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fwww.nxp.com%2Fdownloads%2Fen%2Fnxp%2Fsoftware%2FSW5870.zip%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3ESW5870%3C%2FA%3E%26nbsp%3Bfor%20reference.%20This%2C%20for%20the%20most%20part%2C%20works.%20However%2C%20I%20cannot%20get%20the%20READ%20I2C%20and%20WRITE%20I2C%20commands%20to%20work.%26nbsp%3B%3C%2FP%3E%3CP%3EI%20can%20read%20and%20write%20both%20SRAM%20and%20configuration%20memory%20using%20both%20I%C2%B2C%20and%20NFC%2C%20so%20I%20know%20my%20hardware%20setup%20is%20sound.%26nbsp%3BAccording%20to%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fwww.nxp.com%2Fdocs%2Fen%2Fapplication-note%2FAN12368.pdf%3F_gl%3D1*1p88zhi*_ga*ODYwMTcyOTAuMTc2NDk0NzIwNQ..*_ga_WM5LE0KMSH*czE3NjQ5NDcyMDUkbzEkZzEkdDE3NjQ5NDgxMTIkajYwJGwwJGg3NTM4NTE0OTM.%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EAN12368%2C%3C%2FA%3E%26nbsp%3Ball%20requirements%20for%20these%20two%20commands%20to%20work%20are%20fulfilled%2C%20judging%20from%20the%20readouts%20of%20the%20configuration%20memory.%20All%20I%20get%20on%20the%20android%20side%20is%20the%20response%200x010F%2C%20which%2C%20if%20I%20understand%20correctly%2C%20just%20signals%20there%20is%20an%20error%20and%20that%20the%20error%20code%20is%200x0F.%20This%2C%20in%20turn%2C%20is%20called%20an%20%22unknown%20error%22%20in%20the%20datasheet%2C%20which%20is%20not%20helpful%20at%20all.%20I%20can%20verify%20using%20an%20oscilloscope%20that%20the%20SDA%20and%20SCL%20lines%20don't%20even%20budge%20and%20remain%20high%20due%20to%20the%20external%20pullups.%3CBR%20%2F%3E%3CBR%20%2F%3EI%20have%20tried%20many%20different%20configurations%20and%20combinations%20of%20configuration%20values%2C%20to%20no%20avail.%20I'd%20appreciate%20it%20if%20someone%20more%20familiar%20with%20this%20chip%20could%20help%20me%20out%20on%20this%20or%20give%20me%20a%20pointer.%3CBR%20%2F%3E%3CBR%20%2F%3EHere's%20the%20byte%20buffers%20for%20both%20the%20READ%20and%20WRITE%20commands%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-java%22%3E%3CCODE%3Eval%20write_i2c_cmd%20%3D%20ubyteArrayOf(%0A%20%20%200x12u%2C%20%2F%2F%20flags%0A%20%20%200xD4u%2C%20%2F%2F%20WRITE%20I2C%20constant%0A%20%20%200x04u%2C%20%2F%2F%20manufacturer%20code%0A%20%20%200b00001000u%2C%20%2F%2F%20I2C%20address%0A%20%20%200x00u%2C%20%2F%2F%20N-1%20bytes%20to%20write%0A%20%20%200x00u%20%20%2F%2F%20single%2C%20empty%20data%20byte%0A).toByteArray()%3B%0A%0Aval%20read_i2c_to_sram_cmd%20%3D%20ubyteArrayOf(%0A%20%20%200x12u%2C%20%2F%2F%20flags%0A%20%20%200xD5u%2C%20%2F%2F%20READ%20I2C%20constant%0A%20%20%200x04u%2C%20%2F%2F%20manufacturer%20code%0A%20%20%200b00001000u%2C%20%2F%2F%20I2C%20address%0A%20%20%200x00u%20%20%2F%2F%20N-1%20bytes%20to%20read%0A).toByteArray()%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%3CBR%20%2F%3EIf%20more%20information%20is%20required%2C%20let%20me%20know.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2289655%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20NTP5332%20Read%2FWrite%20I2C%20not%20working%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2289655%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%2C%3C%2FP%3E%0A%3CP%3EIf%20you%20are%20using%20Energy%20Harvesting%2C%20please%20try%20with%20SW3%20-%203%20in%20ON%20position%3B%20also%2C%20USE_CASE_CONF%20should%20be%20set%20to%2001b%20(I2C%20master)%20in%20order%20to%20use%20WRITE%20I2C%20and%20READ%20I2C%20commands.%3C%2FP%3E%0A%3CP%3ERegards%2C%3CBR%20%2F%3EEduardo.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2289181%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20NTP5332%20Read%2FWrite%20I2C%20not%20working%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2289181%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EHello%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F200888%22%20target%3D%22_blank%22%3E%40EduardoZamora%3C%2FA%3E%2C%3CBR%20%2F%3EHappy%20new%20Year%20to%20you%20too%2C%20and%20thanks%20for%20reaching%20out!%3CBR%20%2F%3E%3CBR%20%2F%3EI%20can%20confirm%20the%20following%3A%3CBR%20%2F%3E-%20SW3-3%20is%20OFF%3CBR%20%2F%3E-%20Slave%20mode%20is%20enabled%20(USE_CASE_CONF%20is%20set%20to%2000b)%3CBR%20%2F%3E-%20Multiple%20PORs%20have%20been%20performed%20after%20configuration%2C%20the%20register%20value%20for%20USE_CASE_CONF%20has%20been%20loaded%20correctly%3CBR%20%2F%3E-%20The%20NTAG%205%20is%20the%20only%20I2C%20master%20device%3CBR%20%2F%3E%3CBR%20%2F%3EIn%20the%20meantime%2C%20I%20have%20implemented%20my%20desired%20batch%20transfer%20using%20READ%2FWRITE%20SRAM%20commands%20and%20use%20the%20Event%20detection%20mode%20%22I2C%20to%20NFC%20passthrough%22%20to%20detect%20when%20my%20host%20can%20write%20new%20data.%20This%20works%20fine%20for%20now%2C%20but%20a%20%22proper%22%20solution%20would%20be%20nice%2C%20still.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E