MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
OCOTP: On Chip One-Time Programmable controller.

Overview

The MCUXpresso SDK provides a peripheral driver for the OCOTP module of MCUXpresso SDK devices.

This section contains information describing the requirements for the on-chip eFuse OTP controller along with details about the block functionality and implementation.

OCOTP function group

The OCOTP driver support operaing API to allow read and write the fuse map.

Initialization and de-initialization

The funciton OCOTP_Init() is to initialize the OCOTP with peripheral base address and source clock frequency.

The function OCOTP_Deinit() is to de-initialize the OCOTP controller with peripheral base address.

Read and Write operation

The function OCOTP_ReloadShadowRegister() is to reload the value from the fuse map. this API should be called firstly before reading the register.

The OCOTP_ReadFuseShadowRegister() is to read the value from a given address, if operation is success, a known value will be return, othwise, a value of 0xBADABADA will be returned.

The function OCOTP_WriteFuseShadowRegister() will write a specific value to a known address. please check the return status o make sure whether the access to register is success.

OCOTP example

This example shows how to get the controller version using API. Due to the eFuse is One-Time programmable, example will only print the information of OCOTP controller version. If more operations are needed, please using the API to implement the write and read operation.

Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/ocotp

Enumerations

enum  {
  kStatus_OCOTP_AccessError = MAKE_STATUS(kStatusGroup_SDK_OCOTP, 0),
  kStatus_OCOTP_CrcFail = MAKE_STATUS(kStatusGroup_SDK_OCOTP, 1),
  kStatus_OCOTP_ReloadError,
  kStatus_OCOTP_ProgramFail = MAKE_STATUS(kStatusGroup_SDK_OCOTP, 3),
  kStatus_OCOTP_Locked = MAKE_STATUS(kStatusGroup_SDK_OCOTP, 4)
}
 _ocotp_status Error codes for the OCOTP driver. More...
 

Functions

void OCOTP_Init (OCOTP_Type *base, uint32_t srcClock_Hz)
 Initializes OCOTP controller. More...
 
void OCOTP_Deinit (OCOTP_Type *base)
 De-initializes OCOTP controller. More...
 
static bool OCOTP_CheckBusyStatus (OCOTP_Type *base)
 Checking the BUSY bit in CTRL register. More...
 
static bool OCOTP_CheckErrorStatus (OCOTP_Type *base)
 Checking the ERROR bit in CTRL register. More...
 
static void OCOTP_ClearErrorStatus (OCOTP_Type *base)
 Clear the error bit if this bit is set. More...
 
status_t OCOTP_ReloadShadowRegister (OCOTP_Type *base)
 Reload the shadow register. More...
 
uint32_t OCOTP_ReadFuseShadowRegister (OCOTP_Type *base, uint32_t address)
 Read the fuse shadow register with the fuse addess. More...
 
status_t OCOTP_ReadFuseShadowRegisterExt (OCOTP_Type *base, uint32_t address, uint32_t *data, uint8_t fuseWords)
 Read the fuse shadow register from the fuse addess. More...
 
status_t OCOTP_WriteFuseShadowRegister (OCOTP_Type *base, uint32_t address, uint32_t data)
 Write the fuse shadow register with the fuse addess and data. More...
 
status_t OCOTP_WriteFuseShadowRegisterWithLock (OCOTP_Type *base, uint32_t address, uint32_t data, bool lock)
 Write the fuse shadow register and lock it. More...
 
static uint32_t OCOTP_GetVersion (OCOTP_Type *base)
 Get the OCOTP controller version from the register. More...
 

Driver version

#define FSL_OCOTP_DRIVER_VERSION   (MAKE_VERSION(2, 1, 3))
 OCOTP driver version. More...
 

Macro Definition Documentation

#define FSL_OCOTP_DRIVER_VERSION   (MAKE_VERSION(2, 1, 3))

Enumeration Type Documentation

anonymous enum
Enumerator
kStatus_OCOTP_AccessError 

eFuse and shadow register access error.

kStatus_OCOTP_CrcFail 

CRC check failed.

kStatus_OCOTP_ReloadError 

Error happens during reload shadow register.

kStatus_OCOTP_ProgramFail 

Fuse programming failed.

kStatus_OCOTP_Locked 

Fuse is locked and cannot be programmed.

Function Documentation

void OCOTP_Init ( OCOTP_Type *  base,
uint32_t  srcClock_Hz 
)
Parameters
baseOCOTP peripheral base address.
srcClock_Hzsource clock frequency in unit of Hz. When the macro FSL_FEATURE_OCOTP_HAS_TIMING_CTRL is defined as 0, this parameter is not used, application could pass in 0 in this case.
void OCOTP_Deinit ( OCOTP_Type *  base)
Return values
kStatus_Successupon successful execution, error status otherwise.
static bool OCOTP_CheckBusyStatus ( OCOTP_Type *  base)
inlinestatic

Checking this BUSY bit will help confirm if the OCOTP controller is ready for access.

Parameters
baseOCOTP peripheral base address.
Return values
truefor bit set and false for cleared.
static bool OCOTP_CheckErrorStatus ( OCOTP_Type *  base)
inlinestatic
Parameters
baseOCOTP peripheral base address.
Return values
truefor bit set and false for cleared.
static void OCOTP_ClearErrorStatus ( OCOTP_Type *  base)
inlinestatic
Parameters
baseOCOTP peripheral base address.
status_t OCOTP_ReloadShadowRegister ( OCOTP_Type *  base)

This function will help reload the shadow register without reseting the OCOTP module. Please make sure the OCOTP has been initialized before calling this API.

Parameters
baseOCOTP peripheral base addess.
Return values
kStatus_SuccessReload success.
kStatus_OCOTP_ReloadErrorReload failed.
uint32_t OCOTP_ReadFuseShadowRegister ( OCOTP_Type *  base,
uint32_t  address 
)
Deprecated:
Use OCOTP_ReadFuseShadowRegisterExt instead of this function.
Parameters
baseOCOTP peripheral base address.
addressthe fuse address to be read from.
Returns
The read out data.
status_t OCOTP_ReadFuseShadowRegisterExt ( OCOTP_Type *  base,
uint32_t  address,
uint32_t *  data,
uint8_t  fuseWords 
)

This function reads fuse from address, how many words to read is specified by the parameter fuseWords. This function could read at most OCOTP_READ_FUSE_DATA_COUNT fuse word one time.

Parameters
baseOCOTP peripheral base address.
addressthe fuse address to be read from.
dataData array to save the readout fuse value.
fuseWordsHow many words to read.
Return values
kStatus_SuccessRead success.
kStatus_FailError occurs during read.
status_t OCOTP_WriteFuseShadowRegister ( OCOTP_Type *  base,
uint32_t  address,
uint32_t  data 
)

Please make sure the wrtie address is not locked while calling this API.

Parameters
baseOCOTP peripheral base address.
addressthe fuse address to be written.
datathe value will be writen to fuse address.
Return values
writestatus, kStatus_Success for success and kStatus_Fail for failed.
status_t OCOTP_WriteFuseShadowRegisterWithLock ( OCOTP_Type *  base,
uint32_t  address,
uint32_t  data,
bool  lock 
)

Please make sure the wrtie address is not locked while calling this API.

Some OCOTP controller supports ECC mode and redundancy mode (see reference mananual for more details). OCOTP controller will auto select ECC or redundancy mode to program the fuse word according to fuse map definition. In ECC mode, the 32 fuse bits in one word can only be written once. In redundancy mode, the word can be written more than once as long as they are different fuse bits. Set parameter lock as true to force use ECC mode.

Parameters
baseOCOTP peripheral base address.
addressThe fuse address to be written.
dataThe value will be writen to fuse address.
lockLock or unlock write fuse shadow register operation.
Return values
kStatus_SuccessProgram and reload success.
kStatus_OCOTP_LockedThe eFuse word is locked and cannot be programmed.
kStatus_OCOTP_ProgramFaileFuse word programming failed.
kStatus_OCOTP_ReloadErroreFuse word programming success, but error happens during reload the values.
kStatus_OCOTP_AccessErrorCannot access eFuse word.
static uint32_t OCOTP_GetVersion ( OCOTP_Type *  base)
inlinestatic
Parameters
baseOCOTP peripheral base address.
Return values
returnthe version value.