LPC804 Stuck or crash on IAP_ReadUniqueID

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

LPC804 Stuck or crash on IAP_ReadUniqueID

Jump to solution
1,126 Views
MHMart
Contributor I

I'm trying to read the Unique ID of a LPC804 but, I think it was working before, now I cannot access the UID any longer.

 

The following function makes the whole process stop and not continue. In the debugger I find that IAP_ReadUniqueID is executed (although maybe not with success?) but a breakpoint on the status check is never reached.

 

    uint32_t UIDValue = 0x00;
    status_t UIDStatus = kStatus_Fail;
    //  Read the UID
    UIDStatus = IAP_ReadUniqueID(&UIDValue);
    
    // Return when failed
    if(UIDStatus != kStatus_Success) return;
    
    // insert UID into message
    data[3] = (uint8_t)((UIDValue >> (8 * 3)) & 0xFF);
    data[4] = (uint8_t)((UIDValue >> (8 * 2)) & 0xFF);
    data[5] = (uint8_t)((UIDValue >> (8 * 1)) & 0xFF);
    data[6] = (uint8_t)(UIDValue & 0xFF);

 



Since I think it was working prior, might the flash memory have been emptied or reset? What could it be or what can I check?

0 Kudos
Reply
1 Solution
1,105 Views
ErichStyger
Specialist I

IAP_ReadUniqueID() expects a pointer to 128bits (4 x 32bit values).

You see this if you step into IAP_ReadUniqeID().

You are passing only a pointer to 32bits, so memory gets overwritten. Fix that and it should work.

 

View solution in original post

0 Kudos
Reply
2 Replies
1,106 Views
ErichStyger
Specialist I

IAP_ReadUniqueID() expects a pointer to 128bits (4 x 32bit values).

You see this if you step into IAP_ReadUniqeID().

You are passing only a pointer to 32bits, so memory gets overwritten. Fix that and it should work.

 

0 Kudos
Reply
1,083 Views
MHMart
Contributor I

Thanks, amazing! That solved my issue.

I could, indeed, have figured that out by checking the function.

 


In my defense though, this documentation could be updated to fit that explenation?

https://mcuxpresso.nxp.com/api_doc/dev/2167/a00070.html#ga258d8c49d494cbd0d18321af56e11440

 

Seems an important requirement that isn't mentioned directly.

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-1848850%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ELPC804%20Stuck%20or%20crash%20on%20IAP_ReadUniqueID%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1848850%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI'm%20trying%20to%20read%20the%20Unique%20ID%20of%20a%20LPC804%20but%2C%20I%20think%20it%20was%20working%20before%2C%20now%20I%20cannot%20access%20the%20UID%20any%20longer.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EThe%20following%20function%20makes%20the%20whole%20process%20stop%20and%20not%20continue.%20In%20the%20debugger%20I%20find%20that%20IAP_ReadUniqueID%20is%20executed%20(although%20maybe%20not%20with%20success%3F)%20but%20a%20breakpoint%20on%20the%20status%20check%20is%20never%20reached.%3C%2FP%3E%3CBR%20%2F%3E%3CPRE%20class%3D%22lia-code-sample%20language-c%22%3E%3CCODE%3E%20%20%20%20uint32_t%20UIDValue%20%3D%200x00%3B%0A%20%20%20%20status_t%20UIDStatus%20%3D%20kStatus_Fail%3B%0A%20%20%20%20%2F%2F%20%20Read%20the%20UID%0A%20%20%20%20UIDStatus%20%3D%20IAP_ReadUniqueID(%26amp%3BUIDValue)%3B%0A%20%20%20%20%0A%20%20%20%20%2F%2F%20Return%20when%20failed%0A%20%20%20%20if(UIDStatus%20!%3D%20kStatus_Success)%20return%3B%0A%20%20%20%20%0A%20%20%20%20%2F%2F%20insert%20UID%20into%20message%0A%20%20%20%20data%5B3%5D%20%3D%20(uint8_t)((UIDValue%20%26gt%3B%26gt%3B%20(8%20*%203))%20%26amp%3B%200xFF)%3B%0A%20%20%20%20data%5B4%5D%20%3D%20(uint8_t)((UIDValue%20%26gt%3B%26gt%3B%20(8%20*%202))%20%26amp%3B%200xFF)%3B%0A%20%20%20%20data%5B5%5D%20%3D%20(uint8_t)((UIDValue%20%26gt%3B%26gt%3B%20(8%20*%201))%20%26amp%3B%200xFF)%3B%0A%20%20%20%20data%5B6%5D%20%3D%20(uint8_t)(UIDValue%20%26amp%3B%200xFF)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CBR%20%2F%3E%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3ESince%20I%20think%20it%20was%20working%20prior%2C%20might%20the%20flash%20memory%20have%20been%20emptied%20or%20reset%3F%20What%20could%20it%20be%20or%20what%20can%20I%20check%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1849591%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20LPC804%20Stuck%20or%20crash%20on%20IAP_ReadUniqueID%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1849591%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThanks%2C%20amazing!%20That%20solved%20my%20issue.%3C%2FP%3E%3CP%3EI%20could%2C%20indeed%2C%20have%20figured%20that%20out%20by%20checking%20the%20function.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CBR%20%2F%3EIn%20my%20defense%20though%2C%20this%20documentation%20could%20be%20updated%20to%20fit%20that%20explenation%3F%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fmcuxpresso.nxp.com%2Fapi_doc%2Fdev%2F2167%2Fa00070.html%23ga258d8c49d494cbd0d18321af56e11440%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fmcuxpresso.nxp.com%2Fapi_doc%2Fdev%2F2167%2Fa00070.html%23ga258d8c49d494cbd0d18321af56e11440%3C%2FA%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3ESeems%20an%20important%20requirement%20that%20isn't%20mentioned%20directly.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1848991%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20LPC804%20Stuck%20or%20crash%20on%20IAP_ReadUniqueID%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1848991%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EIAP_ReadUniqueID()%20expects%20a%20pointer%20to%20128bits%20(4%20x%2032bit%20values).%3C%2FP%3E%3CP%3EYou%20see%20this%20if%20you%20step%20into%20IAP_ReadUniqeID().%3C%2FP%3E%3CP%3EYou%20are%20passing%20only%20a%20pointer%20to%2032bits%2C%20so%20memory%20gets%20overwritten.%20Fix%20that%20and%20it%20should%20work.%3C%2FP%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E