Content originally posted in LPCWare by lpcxpresso-support on Tue Jul 29 08:37:55 MST 2014
Quote: martie
Now that I've tried it, I've found that Data and Mask are not expected to be pointers to arrays after all. Instead, the API functions only wrote to the last bank. Otp_ProgGP0() wrote to 0x40045034, Otp_ProgGP1 wrote to 0x40045038 and Otp_ProgGP2 wrote to 0x4004503C. So my question now is, how do I write to the first 2 general purpose banks (lines 0x40045010 and 0x40045020)? Fortunately, I went to an old, partially working board for this test.
To take a step back, OTP memory locations are considered as 4 banks of 4 words, numbered as banks 0 to 3.
The functions to write to banks 0 to 2 are:
bank 0 - Otp_ProgGP0 (&array_Data[0], &array_Mask2[0])
bank 1 - Otp_ProgGP1 (&array_Data[0], &array_Mask2[0])
bank 2 - Otp_ProgGP2 (&array_Data[0], &array_Mask2[0])
These functions take 2 pointers as parameters, the first pointer points to a block of 4 words of data, the second to a 4 word mask.
However, the above functions are not supported on all18xx/43xx parts/revisions - in particular not on flashless parts i.e. parts ending with a "0".
Bank 3 is written via 4 functions:
0x30 or word 0 - Otp_ProgBootSrc and OtpProgJTAGDis
0x34 or word 1 - Otp_ProgGP2_0 or Otp_ProgUSBID
0x38 or word 2 - Otp_ProgGP2_1
0x34 or word 3 - Otp_ProgGP2_2
UM43xx 10503 describes the table of pointers into the OTP ROM functions as:
otp_Init
otp_ProgBootSrc
otp_ProgJTAGDis
otp_ProgUSBID
Reserved
otp_ProgGP0
otp_ProgGP1
otp_ProgGP2
otp_ProgGP2_0
otp_ProgGP2_1
otp_ProgGP2_2
Reserved
Reserved
otp_GenRand
Within this thread there seems to have been confusion between the functions otp_ProgGP<n> and otp_ProgGP2_<n> (where n=0, 1 or 2), both in their naming and their location in the OTP jump table. I hope this clarifies the scheme.
Finally, with respect to writing to banks 0-2 of OTP memory, I would suggest checking the reference manual and any errata to see if these functions are available for the silicon version you are using.