This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SMB/I2C short clocks look like glitches to slave

I am having problems reading reliably over SMBus using the Utils. 

I have tracked down one type of error as an apparent glitch by the TM4C1230 sending out a short clock pulse in the middle of shifting out from the TI Master.  Byte address being sent should be 17x to be a read.  If the glitches are counted as valid pulses, the address would be 17.  The clock before the next glitch would be where the ACK would come (but the slave lost sync by rejecting the glitch, so it didn't pull data low to ack.  

If the glitches were not supposed to be clock pulses, the transmitter stopped clocking too early - there are only 16 full scale pulses in the Read Address / Read Data sequence when there need to be 18.  But there are two short pulses.  This leads me to believe that these pulses are not noise, but are abbreviated clocks.

I don't see any way that the software could shorten the clock pulses. 

Any ideas?

  • Dan Beadle said:
    I am having problems reading reliably over SMBus using the Utils. 

    Find your post very much beyond average in its detail & presentation - good that.

    Yet - you list your issue as one of "reading reliably" which strongly suggests that (some) data transfers occur as expected.    (w/out incident - is this correct?)    If so - have you tested to see if there's something unique to this 0x17 transmission - which aids/abets this (apparent) glitch?

    As always - "single board anomalies" prove the bane of, "remote troubleshoot crue!"    Does this occur across multiple MCU boards - and multiple Slaves?      And - always (and only) with this exact data?    

    May I suggest separate testing - with a different slave device (ideally one requiring a different slave address) to see how/if the issue presents?

    And - you provide no info as to (other) residents - this SMB bus!    (anything present is a suspect - at this early stage)

    "Inside info" - guarded/stored @ vendor's (pristine HQ) always proves of interest - and (somewhere) I recall this 0x17...    (although "fog of battle" dulls link ability to such recall)  

    Might you (further) detail?

  • Thank you.

    Yes, this has the same behavior on multiple boards. We have checked the normal things - power supplies are quiet, trace routing is good.

    I see more errors on the SMB ReadBlock than ReadWord. This makes sense as the blocks are normally 5-25 characters, while words are only 2 bytes.

    There are two batteries attached. Each is on a different SMB port with no other devices.
    The battery is usually "Slave", but may become "master" to broadcast alarms or commands to the charger. This initially created bus faults until I figured out how to handle bus-busy (Usually, just wait for the battery-master to finish it's transfer).

    Yes, this packet works 99.5% of the time.

    I have tested with a non-battery SMBus slave. It is still on the same address, but has a limited number of Smart Battery registers that it supports. It never becomes a master, so I have eliminated the two-master conflicts. I get the same sort of errors.

    Added PEC helps - I can detect an error and retry. Even with up to 5 retries, the packet transfer occasionally fails.

    I am trying to get to 100% reliability - or at least 99.99% after retries.
  • Thank you - 2nd post "out did" your (excellent) initial one.

    And - indeed, "checked the normal things" you (surely) did!

    My firm buys volumes of Li Ion (smart) batteries - assume yours are similar. (ours from firm "S")    If you choose to "id" your smart battery I'll see if we have it (or near equivalent) and repeat your test on (several) of our multi-vendor ARM MCUs.     Such would seem conclusive.
     
    I've some concern about the, "two batteries" attached. Temporarily - till similar glitch occurs - might you try w/just one?

    Believe your test w/"non-battery, SMBus slave - never becoming a master - & w/Smart Bat. registers" was particularly inspired! And its use - revealing the same sort of errors - raises the MCU to, "prime suspect."

    Pardon - but have you "combed" latest/greatest errata?

    I'm (almost) out of tricks - but a repeat of that (most always) failing SMBus "0x17 transaction" via, "bit-bang" may (conclusively) prove some defect w/in vendor MCU's SMBus implementation - would it not?

  • Hello Dan

    And this is with the Glitch filter enabled as in the earlier post from you? Could you send the Baud Rate configuration and System Clock Configuration functions?

    Regards
    Amit
  • Hi Amit,

    As I read - it is your MCU's (output) clock pulse - which (appears) to be glitching!    Is the glitch filter intended to prevent an (MCU output) glitch?

  • Hello cb1,

    Yes, i understand that. The I2C Module works by sampling the SCL on the bus to determine Clock Stretching. So if the glitch is being generated (which I am not sure it will unless at the time of glitch we can determine if a low level was put by the slave) which causes the master to abort the clock but yet sample it as a valid edge, then it would help get a correct clock pulse.

    Regards
    Amit
  • Hi Amit,

    Now I (bit vaguely) recall - thank you.
  • Yes, this is a continuation of the original issue.  

    I found that I was not handling errors from the SMB stack correctly.  When I started handling BUS_BUSY, ARB_LOST, BUS_TIMEOUT, reliability got much, much better.    In that case, I had clocks that were fairly wide - and short.  Once I correctly ( or at least more correctly ) handled these errors, the runt pulses went away.

    My config code is based on using the library reference:

    uint32_t SysClk = SysCtlClockGet();

    SMBusMasterInit(&Context, BaseAddress, SysClk );

    IntPrioritySet( InterruptAddress, 5<<5 );  

    // Set up glitch filter.

    I2CMasterGlitchFilterConfigSet( BaseAddress, I2C_MASTER_GLITCH_FILTER_32); // todo

    SMBusMasterIntEnable( &Context );

    MTPR was correctly set at 18x (100Khz).

    The set up of the glitch filter does not appear to be correct when I use the call to I2CMasterGlitchConfigSet.

    void
    I2CMasterGlitchFilterConfigSet(uint32_t ui32Base, uint32_t ui32Config)
    {
    //
    // Check the arguments.
    //
    ASSERT(_I2CBaseValid(ui32Base));

    //
    // Configure the glitch filter field of MTPR.
    //
    HWREG(ui32Base + I2C_O_MTPR) |= ui32Config;
    }

    It is attempting to write to the MTPR which has no bits in the shifted position.  It should be writing to I2C4MCR2.  Also, it never sets up the GFE bit in I2C4MCR.

    This is the code that I used from the TivaWare_C_Series-2.10.0.12573 library:

    //*****************************************************************************
    //
    //! Configures the I2C Master glitch filter.
    //!
    //! \param ui32Base is the base address of the I2C module.
    //! \param ui32Config is the glitch filter configuration.
    //!
    //! This function configures the I2C Master glitch filter. The value passed in
    //! to \e ui32Config determines the sampling range of the glitch filter, which
    //! is configurable between 1 and 32 system clock cycles. The default
    //! configuration of the glitch filter is 0 system clock cycles, which means
    //! that it's disabled.
    //!
    //! The \e ui32Config field should be any of the following values:
    //!
    //! - \b I2C_MASTER_GLITCH_FILTER_DISABLED
    //! - \b I2C_MASTER_GLITCH_FILTER_1
    //! - \b I2C_MASTER_GLITCH_FILTER_2
    //! - \b I2C_MASTER_GLITCH_FILTER_3
    //! - \b I2C_MASTER_GLITCH_FILTER_4
    //! - \b I2C_MASTER_GLITCH_FILTER_8
    //! - \b I2C_MASTER_GLITCH_FILTER_16
    //! - \b I2C_MASTER_GLITCH_FILTER_32
    //!
    //! \note Not all Tiva devices support this function. Please consult the
    //! device data sheet to determine if this feature is supported.
    //!
    //! \return None.
    //
    //*****************************************************************************
    void
    I2CMasterGlitchFilterConfigSet(uint32_t ui32Base, uint32_t ui32Config)
    {
    //
    // Check the arguments.
    //
    ASSERT(_I2CBaseValid(ui32Base));

    //
    // Configure the glitch filter field of MTPR.
    //
    HWREG(ui32Base + I2C_O_MTPR) |= ui32Config;
    }

    It is clear that it is putting the value into the wrong register.  It should be MCR2 per the datasheet The defines for the values are also wrong:

    #define I2C_MASTER_GLITCH_FILTER_32 \
    0x00070000

    Finally, the routine doesn't set the GFE bit of MCR.  

    I will change my code to:

    HWREG(BaseAddress + I2C_O_MCR2 |= 7<<4; // Set to 31 clock glitch filter

    HWREG(BaseAddress + I2C_O_MCR) |= I2C_MCR_GFE; // and enable now

    I should have checked the registers earlier.  I had hoped to leverage libraries.  

    I will let you know how this works.

  • I made the changes and ran 100,000 messages (32 different registers, ranging from 2 byte to 30 byte transfers) with no errors.

    So, as you pointed out a couple months ago, the problem was the Glitch Filter settings.

    Shame on me for trusting the libraries. Is there a way to report a bug against them?

    Thanks for all your help. CB1, you helped too by asking your last glitch question. Thanks!

    Dan Beadle
  • Hello Dan,

    See the note in the function. TM4C123 devices are not supported and this mechanism of having only setting the Glitch value suppression to the MTPR is for TM4C129.

    //! \note Not all Tiva devices support this function. Please consult the
    //! device data sheet to determine if this feature is supported.

    Point Noted and I have filed a bug on your behalf.

    Regards
    Amit
  • I did see the note, and the TM4C1230 does support glitch filters. I didn't dig into the library enough.

    Again, than you for all your help.
  • Thanks. I did see the note. The TM4C1230 does support Glitch Filters, just not in the same registers.

    Should I have looked elsewhere?

    I definitely didn't examine the code until today.

    I appreciate the help. I should have checked the registers months ago.
  • Hello Dan

    Or may be we should have done a better job of checking the software for the correct function... There is a bunch of document updates being planned so we can go and update Driver Lib User Guide appropriately.

    Regards
    Amit
  • Amit Ashara said:
    There are a bunch of document updates being planned so we can go and update Driver Lib User Guide appropriately.

    Hi Amit,

    Surely your group has given great thought to these updates.      And they'll be received with joy by many users.

    That said - might a simple listing of those updates here (i.e. no great detail - rather just the names/targets of the updates) prove worthwhile?     Your user-clients here may well be able to suggest: additions, prioritizing of those updates, & other "useful comments/feedback."    

    We note that "Community Feedback" is often helpful - appears that it could enhance/enrich your, "planned document updates."    (i.e. many more eyes/ears/ideas often improves the "appropriateness" of work done by a, "select few!")       And - of some note - we're free!

  • Hello cb1,

    Boot Loader and Driverlib guide files are for the first of the documents. USB Library (on a/c of complexity) at a later date. Since the list of issues is long, it would be worthwhile to start a sticky thread on the forum to get consolidation of feedback.

    Regards
    Amit
  • Thank you, Amit.

    Sticky thread is vendor controlled/initiated - I believe.

    Involving your client-user base seems to make sense. Sometimes those "too close" - cannot really or fully sense the concerns & issues of those with high desire - but lesser "day to day" involvement. Thus this request for (some) user voice to guide these updates to highest use & value...
  • Hello cb1,

    Please start it and I will stick-"y" it.

    Regards
    Amit
  • Hi Amit,

    Deed done!
    e2e.ti.com/.../423619
  • I also have just come across this problem. Using a TM4C123G launchpad in I2C mode, I randomly get runt clock pulses. They are rare, and setting the glitch filter seems to help, although the errata indicates that the glitch filter has problems and may or may not work (see SPMZ849E). I'm using TivaWare 2.1.2.111 and the above mentioned problem with I2CMasterGlitchFilterConfigSet has been fixed, it now seems to work with TM4C123's
    Mike
  • Hello Mike

    The testing of the glitch filter did indicate that over extensive glitch generation and changing positions, it may fail. The condition is very corner case and in field we have not seen it failing yet. However it is always important to let the customer know of the same.

    Regards
    Amit