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.

TM4C129XNCZAD: TM4C OneWire Application Note: Enumeration Error

Part Number: TM4C129XNCZAD

Hello,

there seems to be an error in the spma057 example code (Rev C): http://www.ti.com/general/docs/litabsmultiplefilelist.tsp?literatureNumber=spma057

The problem occurs with the first conflict with the first ROM ID to be read and appears like this:

  1. Starting condition: i32ConflictBitNumber = -1 (signed), ui32BitNumber = 0 (unsigend), i32NumSlaves =0 (signed)
  2. Due to an implicit type conversoin in line 376, the comparision enters the else path
  3.                 else if(ui32BitNumber > i32ConflictBitNumber)
                    {

  4. With the access of the previous ROM ID, and i32NumSlaves=0 we exceed the boundaries of the ROM ID array, causing unpredictable code execution
//
// Take the path of the PREVIOUS ROM number.
// Get the last path from last ROM number found
//
ui32WriteBit = ((g_pui64SlaveAddr[i32NumSlaves-1]
							 >> ui32BitNumber) & 1);

In most cases this does not cause severe problems, since the invalid array locatoin is only read and the algorithm will continue to work for all other conflict positions.

However I had some issues with IDs not being found due to this issue. Since it depends on the memory layout it's a bit frustrating to debug.

@TI support: Can you confirm this? And would you please update your example code with either of the following fixes:

  1. line 376
else if((int32_t)ui32BitNumber > i32ConflictBitNumber)
{

2. line 199

    //
    // Number of the bit under cosideration in the perticular iteration.
    //
    int32_t ui32BitNumber;

best regards

Fabian