element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Azure Sphere Starter Kit
  • Products
  • Dev Tools
  • Avnet Boards Community
  • Azure Sphere Starter Kit
  • More
  • Cancel
Azure Sphere Starter Kit
Forum Repeated first byte on I2C read with Azure Sphere
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Azure Sphere Starter Kit to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 12 replies
  • Answers 5 answers
  • Subscribers 47 subscribers
  • Views 1435 views
  • Users 0 members are here
  • i2c
  • pn7120
  • mt3620
Related

Repeated first byte on I2C read with Azure Sphere

Fred27
Fred27 over 6 years ago

I've been trying to get the PN7120 based NFC click working with the Avnet Azure Sphere starter kit. It's not been easy. I should have been more wary after my road test of the similar PN7150.

 

The weirdest problem of many was the fact that the output buffer meant that you might have 2 attempts at request A because the first one failed, make request B and get the buffered answer to one of the request A's that you made earlier. As the only documentation is sample code like this (which I've simplified significantly to illustrate the point), and the responses seem undocumented and fairly similar, it wasn't easy to debug.

 

// Retry this until it succeeds...
NxpNci_HostTransceive(NCICoreReset, sizeof(NCICoreReset), Answer, sizeof(Answer), &AnswerSize);
if ((Answer[0] != 0x40) || (Answer[1] != 0x00))
    return NXPNCI_ERROR;

// Then try this...
NxpNci_HostTransceive(NCICoreInit, sizeof(NCICoreInit), Answer, sizeof(Answer), &AnswerSize);
if ((Answer[0] != 0x40) || (Answer[1] != 0x01) || (Answer[3] != 0x00))
    return NXPNCI_ERROR;

 

This might be a UK thing, but it reminded me of this:

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

Anyway, I think I've got round all the quirks of the NFC click's PN7120 - and I'll post some example code once it's tidied.

 

 

The problem I have now seems to be an MT3620 one. I frequently (but not consistently) get a stray byte at the start of my response. Sometimes it's the first byte repeated. Sometimes it's 0xFF. Perhaps it could be left over from the last response. I've written code to detect and remove it, but it really shouldn't be there. I've taken a close look at my code and nothing is out of the ordinary. The error comes back from the I2CMaster_Read function in the Azure Sphere SDK.

 

Has anyone seen this problems before or have any other ideas?

image

image

  • Sign in to reply
  • Cancel

Top Replies

  • Fred27
    Fred27 over 6 years ago in reply to clem57 +2 suggested
    clem57 wrote: OK on a more serious note, look at https://ez.analog.com/audio/f/q-a/3553/i2c-timing-issues-with-ssm2529 . It suggests the need for a pull up resistor. But that may cause parasitic capacitance…
  • clem57
    clem57 over 6 years ago +1
    The video is funny. Not withstanding your issue of course.
  • clem57
    clem57 over 6 years ago +1 suggested
    OK on a more serious note, look at https://ez.analog.com/audio/f/q-a/3553/i2c-timing-issues-with-ssm2529 . It suggests the need for a pull up resistor. But that may cause parasitic capacitance. Read https…
Parents
  • javagoza
    0 javagoza over 6 years ago

    I have had similar problems working with the Uart with the POXIS read and write functions. I solved the problem by doing the readings and writings in separate threads and adding nano sleeps in the threads to let the uart data be read or written.

     

    Maybe this is not yout problem as I2C Azure Sphere operations are all blocking, synchronous operations. In the UART only asynchronous operations are supported by now.

    Perhaps you can increment the timeout ( I2CMaster_SetTimeout) or make a delay before reading.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • Fred27
    0 Fred27 over 6 years ago in reply to javagoza

    I'm already writing, waiting for IRQ to go high and then reading. There's a few ms between sending the command (off-screen to the left on the 'scope screenshot) and reading the response. I had similar problems without the delay - i.e. using I2CMaster_WriteThenRead.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • Fred27
    0 Fred27 over 6 years ago in reply to javagoza

    I'm already writing, waiting for IRQ to go high and then reading. There's a few ms between sending the command (off-screen to the left on the 'scope screenshot) and reading the response. I had similar problems without the delay - i.e. using I2CMaster_WriteThenRead.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube