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:
- Starting condition: i32ConflictBitNumber = -1 (signed), ui32BitNumber = 0 (unsigend), i32NumSlaves =0 (signed)
- Due to an implicit type conversoin in line 376, the comparision enters the else path
-
else if(ui32BitNumber > i32ConflictBitNumber) {
- 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:
- 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