TLE986x Device Family SDK
Data Structures | Macros | Functions | Variables
bootrom.h File Reference

Go to the source code of this file.

Detailed Description

BootROM low level access library.

Version
V0.3.0
Date
12. Oct 2020

Include Graph

Include dependency graph for bootrom.h:

Data Structures

union  TCustomerID
 This union defines the return parameter of GetCustomerID. More...
 
struct  TData
 
union  T100TP_Data
 These structs define the input data structure for USER_100TP_PROG. More...
 
union  TUser_100TP_Prog
 This union defines the return value of USER_100TP_PROG. More...
 
union  TProgFlag
 This struct defines the option flag for the USER_PROG function. More...
 
union  TUser_Prog
 This union defines the return value of USER_PROG. More...
 
union  TUser_OpenAB
 This union defines the return value of USER_OPENAB. More...
 
union  TUser_MAPRAM_Init
 This union defines the return value of USER_MAPRAM_INIT. More...
 
union  TUser_NVM_ECC_Check
 This union defines the return value of USER_NVM_ECC_CHECK. More...
 
union  TUser_ECC_Check
 This union defines the return value of USER_ECC_CHECK. More...
 
union  TUser_ERASE_SECTOR_VERIFY
 BF-Step only: This union defines the return value of USER_ERASE_SECTOR_VERIFY. More...
 
union  TUser_ERASEPG_VERIFY
 BF-Step only: This union defines the return value of USER_ERASEPG_VERIFY. More...
 
union  TUser_VERIFY_PAGE
 BF-Step only: This union defines the return value of USER_VERIFY_PAGE. More...
 

Macros

#define FlashPageSize   (128U)
 
#define FlashSectorSize   (4096U)
 
#define addr_USER_CFLASH_WR_PROT_EN   (0x3925u)
 
#define addr_USER_CFLASH_WR_PROT_DIS   (0x391Du)
 
#define addr_USER_CFLASH_RD_PROT_EN   (0x3915u)
 
#define addr_USER_CFLASH_RD_PROT_DIS   (0x390Du)
 
#define addr_USER_DFLASH_WR_PROT_EN   (0x3905u)
 
#define addr_USER_DFLASH_WR_PROT_DIS   (0x38FDu)
 
#define addr_USER_DFLASH_RD_PROT_EN   (0x38F5u)
 
#define addr_USER_DFLASH_RD_PROT_DIS   (0x38EDu)
 
#define addr_USER_OPENAB   (0x38E5u)
 
#define addr_USER_PROG   (0x38DDu)
 
#define addr_USER_ERASEPG   (0x38D5u)
 
#define addr_USER_ABORTPROG   (0x38CDu)
 
#define addr_USER_NVMRDY   (0x38C5u)
 
#define addr_USER_READ_CAL   (0x38BDu)
 
#define addr_USER_NVM_CONFIG   (0x38B5u)
 
#define addr_USER_NVM_ECC2ADDR   (0x38ADu)
 
#define addr_USER_MAPRAM_INIT   (0x389Du)
 
#define addr_USER_READ_100TP   (0x3875u)
 
#define addr_USER_100TP_PROG   (0x386Du)
 
#define addr_USER_ERASE_SECTOR   (0x3865u)
 
#define addr_USER_RAM_MBIST_START   (0x384Du)
 
#define addr_USER_NVM_ECC_CHECK   (0x3845u)
 
#define addr_USER_ECC_CHECK   (0x383Du)
 
#define addr_USER_ERASEPG_VERIFY   (0x3885u)
 
#define addr_USER_ERASE_SECTOR_VERIFY   (0x388Du)
 
#define addr_USER_VERIFY_PAGE   (0x3895u)
 

Functions

uint8 ProgramPage (uint32 addr, const uint8 *buf, uint8 Branch, uint8 Correct, uint8 FailPageErase)
 Programms a page to NVM. More...
 
bool GetCustomerID (const TCustomerID *CustID)
 Reads the Customer ID out of the 100TP NVM. More...
 

Variables

bool(*const USER_CFLASH_WR_PROT_EN )(uint16 cflash_pw)
 Sets the temporary code flash write protection. The password is compared against the. More...
 
bool(*const USER_CFLASH_WR_PROT_DIS )(uint16 cflash_pw)
 Removes the temporary code flash write protection. The password is compared against the. More...
 
bool(*const USER_CFLASH_RD_PROT_EN )(uint16 cflash_pw)
 Sets the temporary code flash read protection. The password is compared against the. More...
 
bool(*const USER_CFLASH_RD_PROT_DIS )(uint16 cflash_pw)
 Removes the temporary code flash read protection. The password is compared against the. More...
 
bool(*const USER_DFLASH_WR_PROT_EN )(uint16 dflash_pw)
 Sets the temporary data flash write protection. The password is compared against the. More...
 
bool(*const USER_DFLASH_WR_PROT_DIS )(uint16 dflash_pw)
 Removes the temporary data flash write protection. The password is compared against the. More...
 
bool(*const USER_DFLASH_RD_PROT_EN )(uint16 dflash_pw)
 Sets the temporary data flash read protection. The password is compared against the. More...
 
bool(*const USER_DFLASH_RD_PROT_DIS )(uint16 dflash_pw)
 Removes the temporary data flash read protection. The password is compared against the. More...
 
uint8(*const USER_OPENAB )(const uint32 NVMPAGEAddr)
 Opens the assembly buffer for writing to a flash page, for code flash as well as data flash. More...
 
uint8(*const USER_PROG )(const uint8 PROG_FLAG)
 Writes the assembly buffer content to the flash page addressed by USER_OPENAB. More...
 
uint8(*const USER_ERASEPG )(const uint32 *NVMPageAddr, const uint8 XRAM_RTNE_BRNCHNG)
 Erases a flash page, for code flash as well as data flash. More...
 
bool(*const USER_ABORTPROG )(void)
 Closes the Assembly Buffer. More...
 
bool(*const USER_NVMRDY )(void)
 Returns the status of the NVM module. More...
 
uint8(*const USER_READ_CAL )(const uint8 NumOfBytes, const uint8 CSAddr, const uint16 RAMAddr)
 Reads the NVM calibration data. More...
 
bool(*const USER_NVM_CONFIG )(const uint8 *NVMSize, const uint8 *MapRAMSize)
 Reads the total size of code flash and total size of data flash for this device. More...
 
uint8(*const USER_NVM_ECC2ADDR )(const uint16 *ecc2addr)
 This function returns the last NVM address causing a double bit ECC failure. More...
 
uint8(*const USER_MAPRAM_INIT )(void)
 This function performs a MapRAM reinitialization. More...
 
bool(*const USER_READ_100TP )(const uint8 OTP_Page_Sel, const uint8 DataOffset, const uint32 *HundredTPData)
 This function reads four bytes from a selected 100TP page. More...
 
uint8(*const USER_100TP_PROG )(const uint8 OTP_Page_Sel)
 This function writes data to a selected 100TP page. More...
 
uint8(*const USER_ERASE_SECTOR )(const uint32 NVMSectorAddr)
 This function performs a sector erase. More...
 
uint8(*const USER_RAM_MBIST_START )(const uint16 RAM_MBIST_Stop_Addr, const uint16 RAM_MBIST_Start_addr)
 This function performs a MBIST on the RAM for a given address range. More...
 
uint8(*const USER_NVM_ECC_CHECK )(void)
 This function performs a ECC check on the entire NVM by reading the same. More...
 
uint8(*const USER_ECC_CHECK )(const uint32 *ecc2addr)
 This function returns the address of the last ECC fail. More...
 
uint8(*const USER_ERASE_SECTOR_VERIFY )(const uint32 sector_addr)
 This function performs a verify on an erased sector. More...
 
uint8(*const USER_ERASEPG_VERIFY )(const uint32 page_addr)
 This function performs a verify on an erased page. More...
 
uint8(*const USER_VERIFY_PAGE )(const uint32 page_addr)
 This function performs a verify on a programmed page. More...
 

Macro Definition Documentation

◆ addr_USER_100TP_PROG

#define addr_USER_100TP_PROG   (0x386Du)

◆ addr_USER_ABORTPROG

#define addr_USER_ABORTPROG   (0x38CDu)

◆ addr_USER_CFLASH_RD_PROT_DIS

#define addr_USER_CFLASH_RD_PROT_DIS   (0x390Du)

◆ addr_USER_CFLASH_RD_PROT_EN

#define addr_USER_CFLASH_RD_PROT_EN   (0x3915u)

◆ addr_USER_CFLASH_WR_PROT_DIS

#define addr_USER_CFLASH_WR_PROT_DIS   (0x391Du)

◆ addr_USER_CFLASH_WR_PROT_EN

#define addr_USER_CFLASH_WR_PROT_EN   (0x3925u)

◆ addr_USER_DFLASH_RD_PROT_DIS

#define addr_USER_DFLASH_RD_PROT_DIS   (0x38EDu)

◆ addr_USER_DFLASH_RD_PROT_EN

#define addr_USER_DFLASH_RD_PROT_EN   (0x38F5u)

◆ addr_USER_DFLASH_WR_PROT_DIS

#define addr_USER_DFLASH_WR_PROT_DIS   (0x38FDu)

◆ addr_USER_DFLASH_WR_PROT_EN

#define addr_USER_DFLASH_WR_PROT_EN   (0x3905u)

◆ addr_USER_ECC_CHECK

#define addr_USER_ECC_CHECK   (0x383Du)

◆ addr_USER_ERASE_SECTOR

#define addr_USER_ERASE_SECTOR   (0x3865u)

◆ addr_USER_ERASE_SECTOR_VERIFY

#define addr_USER_ERASE_SECTOR_VERIFY   (0x388Du)

◆ addr_USER_ERASEPG

#define addr_USER_ERASEPG   (0x38D5u)

◆ addr_USER_ERASEPG_VERIFY

#define addr_USER_ERASEPG_VERIFY   (0x3885u)

◆ addr_USER_MAPRAM_INIT

#define addr_USER_MAPRAM_INIT   (0x389Du)

◆ addr_USER_NVM_CONFIG

#define addr_USER_NVM_CONFIG   (0x38B5u)

◆ addr_USER_NVM_ECC2ADDR

#define addr_USER_NVM_ECC2ADDR   (0x38ADu)

◆ addr_USER_NVM_ECC_CHECK

#define addr_USER_NVM_ECC_CHECK   (0x3845u)

◆ addr_USER_NVMRDY

#define addr_USER_NVMRDY   (0x38C5u)

◆ addr_USER_OPENAB

#define addr_USER_OPENAB   (0x38E5u)

◆ addr_USER_PROG

#define addr_USER_PROG   (0x38DDu)

◆ addr_USER_RAM_MBIST_START

#define addr_USER_RAM_MBIST_START   (0x384Du)

◆ addr_USER_READ_100TP

#define addr_USER_READ_100TP   (0x3875u)

◆ addr_USER_READ_CAL

#define addr_USER_READ_CAL   (0x38BDu)

◆ addr_USER_VERIFY_PAGE

#define addr_USER_VERIFY_PAGE   (0x3895u)

◆ FlashPageSize

#define FlashPageSize   (128U)

◆ FlashSectorSize

#define FlashSectorSize   (4096U)

Function Documentation

◆ GetCustomerID()

bool GetCustomerID ( const TCustomerID CustID)

Reads the Customer ID out of the 100TP NVM.

Note
This function violates [MISRA 2012 Rule 19.2, advisory], [MISRA 2012 Rule 11.3, required], [MISRA 2012 Rule 11.5, advisory]
Parameters
*CustIDpointer to the struct where the Customer ID will be stored
Returns
0 = pass
1 = fail

Example

This example reads the Customer ID out of the first 100TP page.

void Example_Function(void)
{
TCustomerID custid;
(void)GetCustomerID(&custid);
}

◆ ProgramPage()

uint8 ProgramPage ( uint32  addr,
const uint8 buf,
uint8  Branch,
uint8  Correct,
uint8  FailPageErase 
)

Programms a page to NVM.

Note
This function violates [MISRA Rule 45]
Parameters
addrlogical address of the page to be programmed
*bufdata buffer containing the data to be programmed, array of 128 bytes
Branch0 = no RAM branch,
1 = RAM branch
Correct0 = no corrective actions (retry/disturb handling) on verify fail
1 = corrective actions (retry/dirsturb handling) enabled
FailPageErase0 = enabled, old data is kept,
1 = disable, old data erased
Returns
0 = pass,
1 = fail

Example

This example fills an array of 128 bytes with house numbers.

The page_data array will then be programmed to the first page

of the data flash.
The page programming is executed with no RAM branch,

with corrective actions (retry) and old data is kept in case of fail.

void Example_Function(void)
{
uint8 page_data[128];
uint8 i;
for ( i = 0; i < FlashPageSize; i++)
{
page_data[i] = i;
}
if ( ProgramPage(DataFlashStart, &page_data, 0, 1, 0) == 1)
{
}
(void)WDT1_Service();
}

Variable Documentation

◆ USER_100TP_PROG

uint8(*const USER_100TP_PROG) (const uint8 OTP_Page_Sel)

This function writes data to a selected 100TP page.

In order to write data to a 100TP page, the data has to be set up in a structure residing in RAM.

The structure has the following outline:

RAM preloading for 100 Time Programmable page programming
RAM Address Function
0x18000400Number of Bytes to be programmed,
max. 127
0x18000401page offset 1
0x18000402page data 1
0x18000403page offset 2
0x18000404page data 2
......
0x18000401 + ((N-1) x 2)page offset N
0x18000402 + ((N-1) x 2)page data N
Parameters
OTP_Page_Selselects one out of eight 100TP pages, 0x11 is page 1, 0x12 is page 2, ..., 0x18 is page 8
Return values
true= pass
false= fail

Example

This example writes house numbers to the 2nd 100TP page.

void Example_Function(void)
{
//program 100TP page 2
uint8 page = 0x12;
uint8 i;
nvm100tp.count = 127;
for ( i = 0; i < nvm100tp.count; i++ )
{
nvm100tp.data[i].offset = i;
nvm100tp.data[i].date = i;
}
res.reg = USER_100TP_PROG(page);
(void)WDT1_Service();
if (res.bit.GlobFail == 1)
{
...any fail has happened
}
}

◆ USER_ABORTPROG

bool(*const USER_ABORTPROG) (void)

Closes the Assembly Buffer.

Return values
true= Assembly Buffer closed
false= Assembly buffer could not be close, programming already started

Example

This example closes the Assembly Buffer intentionally.

void Example_Function(void)
{
TUser_OpenAB openab_res;
(void)WDT1_Service();
if ( openab_res.bit.ExecFail == 1 )
{
//Assembly buffer is already open, or
//nested NVM operation
}
if ( openab_res.bit.ABFail == 1 )
{
//data flash write protected, or
//wrong NVMPAGEAddr address, not within flash range
}
if ( USER_ABORTPROG() == true)
{
//assembly buffer closed, programming preparation aborted
}
}

◆ USER_CFLASH_RD_PROT_DIS

bool(*const USER_CFLASH_RD_PROT_DIS) (uint16 cflash_pw)

Removes the temporary code flash read protection. The password is compared against the.

password stored in the 100TP page 1 offset 0x0C. The default password is 0x0000.

Note
The Read Protection acts as a IP protection, but in order to enable full IP protection use the protection set via BSL mode (permanent) instead.
Parameters
cflash_pwpassword to validate function execution
Return values
0= pass,
1= fail, password doesn't match

Example

This example removes the temporary code flash read protection by using the default password.

void Example_Function(void)
{
{
//code flash no longer read protected
}
else
{
//code flash still read protected, password did not match
}
(void)WDT1_Service();
}

◆ USER_CFLASH_RD_PROT_EN

bool(*const USER_CFLASH_RD_PROT_EN) (uint16 cflash_pw)

Sets the temporary code flash read protection. The password is compared against the.

password stored in the 100TP page 1 offset 0x0C. The default password is 0x0000.

Note
The Read Protection acts as a IP protection, but in order to enable full IP protection use the protection set via BSL mode (permanent) instead.
Parameters
cflash_pwpassword to validate function execution
Return values
0= pass,
1= fail, password doesn't match

Example

This example sets the temporary code flash read protection by using the default password.

void Example_Function(void)
{
if ( USER_CFLASH_RD_PROT_EN(0) == 0)
{
//read protection set
}
else
{
//...careful, protection not set, password did not match
}
(void)WDT1_Service();
}

◆ USER_CFLASH_WR_PROT_DIS

bool(*const USER_CFLASH_WR_PROT_DIS) (uint16 cflash_pw)

Removes the temporary code flash write protection. The password is compared against the.

password stored in the 100TP page 1 offset 0x0C. The default password is 0x0000.

Note
The write protection is recommended to prevent the code flash from being erased/written unintentionally.
Parameters
cflash_pwpassword to validate function execution
Return values
0= pass,
1= fail, password doesn't match

Example

This example removes the temporary code flash write protection by using the default password.

void Example_Function(void)
{
{
//code flash no longer write protected
}
else
{
//code flash still write protected, password did not match
}
(void)WDT1_Service();
}

◆ USER_CFLASH_WR_PROT_EN

bool(*const USER_CFLASH_WR_PROT_EN) (uint16 cflash_pw)

Sets the temporary code flash write protection. The password is compared against the.

password stored in the 100TP page 1 offset 0x0C. The default password is 0x0000.

Note
The write protection is recommended to prevent the code flash from being erased/written unintentionally.
Parameters
cflash_pwpassword to validate function execution
Return values
0= pass,
1= fail, password doesn't match

Example

This example sets the temporary code flash write protection by using the default password.

void Example_Function(void)
{
if ( USER_CFLASH_WR_PROT_EN(0) == 0)
{
//write protection set
}
else
{
//...careful, protection not set, password did not match
}
(void)WDT1_Service();
}

◆ USER_DFLASH_RD_PROT_DIS

bool(*const USER_DFLASH_RD_PROT_DIS) (uint16 dflash_pw)

Removes the temporary data flash read protection. The password is compared against the.

password stored in the 100TP page 1 offset 0x0E. The default password is 0x0000.

Parameters
dflash_pwpassword to validate function execution
Return values
0= pass,
1= fail, password doesn't match

Example

This example removes the temporary data flash read protection by using the default password.

void Example_Function(void)
{
{
//data flash no longer read protected
}
else
{
//data flash still read protected, password did not match
}
(void)WDT1_Service();
}

◆ USER_DFLASH_RD_PROT_EN

bool(*const USER_DFLASH_RD_PROT_EN) (uint16 dflash_pw)

Sets the temporary data flash read protection. The password is compared against the.

password stored in the 100TP page 1 offset 0x0E. The default password is 0x0000.

Parameters
dflash_pwpassword to validate function execution
Return values
0= pass,
1= fail, password doesn't match

Example

This example sets the temporary data flash read protection by using the default password.

void Example_Function(void)
{
if ( USER_DFLASH_RD_PROT_EN(0) == 0)
{
//write protection set
}
else
{
//...careful, protection not set, password did not match
}
(void)WDT1_Service();
}

◆ USER_DFLASH_WR_PROT_DIS

bool(*const USER_DFLASH_WR_PROT_DIS) (uint16 dflash_pw)

Removes the temporary data flash write protection. The password is compared against the.

password stored in the 100TP page 1 offset 0x0E. The default password is 0x0000.

Parameters
dflash_pwpassword to validate function execution
Return values
0= pass,
1= fail, password doesn't match

Example

This example removes the temporary data flash write protection by using the default password.

void Example_Function(void)
{
{
//data flash no longer write protected
}
else
{
//data flash still write protected, password did not match
}
(void)WDT1_Service();
}

◆ USER_DFLASH_WR_PROT_EN

bool(*const USER_DFLASH_WR_PROT_EN) (uint16 dflash_pw)

Sets the temporary data flash write protection. The password is compared against the.

password stored in the 100TP page 1 offset 0x0E. The default password is 0x0000.

Parameters
dflash_pwpassword to validate function execution
Return values
0= pass,
1= fail, password doesn't match

Example

This example sets the temporary data flash write protection by using the default password.

void Example_Function(void)
{
if ( USER_DFLASH_WR_PROT_EN(0) == 0)
{
//write protection set
}
else
{
//...careful, protection not set, password did not match
}
(void)WDT1_Service();
}

◆ USER_ECC_CHECK

uint8(*const USER_ECC_CHECK) (const uint32 *ecc2addr)

This function returns the address of the last ECC fail.

Returns
uint8
Bit 0: single bit errors (SBE)
       0 = pass, no SBEs detected
       1 = fail, at least one SBE detected
Bit 1: Double bit errors (DBE)
       0 = pass, no DBEs detected
       1 = fail, at least one DBE detected
Bit 7: Execution status
       0 = pass, routine executed successfully
       1 = fail, routine failed to execute, due to nested call

Example

This example performs a ECC check on the entire flash.

void Example_Function(void)
{
TUser_ECC_Check res_addr;
uint32 fail_addr;
res_check.reg = USER_NVM_ECC_CHECK();
(void)WDT1_Service();
if ( res_check.bit.SBE == 1 )
{
//single bit error, will be corrected during runtime
}
if ( res_check.bit.DBE == 1 )
{
res_addr.reg = USER_ECC_CHECK( &fail_addr );
if ( res_addr.bit.SBE == 1)
{
//fail_addr points to a Single Bit Error
}
if ( res_addr.bit.DBE == 1)
{
//fail_addr points to a Double Bit Error
}
if ( res_addr.bit.ExecFail == 1)
{
//fail_addr not valid, function could not be executed
}
}
if ( res_check.bit.ExecFail == 1)
{
//ECC check could not be performed
}
}

◆ USER_ERASE_SECTOR

uint8(*const USER_ERASE_SECTOR) (const uint32 NVMSectorAddr)

This function performs a sector erase.

Parameters
NVMSectorAddraddress of the sector which will be erased
Returns
uint8
Bit 0: function status, OR'd all flags
       0 = pass, sector erase successful
       1 = fail, sector erase failed
Bit 7: Execution status
       0 = pass, routine executed successfully
       1 = fail, routine failed to execute, due to sector protected, or nested call

Example

This example erases the data flash sector.

void Example_Function(void)
{
uint8 res;
(void)WDT1_Service();
if ( res != 0 )
{
...any fail has happened
}
}

◆ USER_ERASE_SECTOR_VERIFY

uint8(*const USER_ERASE_SECTOR_VERIFY) (const uint32 sector_addr)

This function performs a verify on an erased sector.

This function checks if all pages within the sector are in proper erased state.

For the data flash sector it checks whether none of the pages are mapped and whether

a valid Spare Page is available an in proper erased state.

Note
BF-Step only.
Parameters
sector_addraddress of the sector which will be verified
Returns
uint8 (see TUser_ERASE_SECTOR_VERIFY)
Bit 0: GlobFail, function status, OR'd all flags
       0 = pass, sector erase verify successful
       1 = fail, sector erase verify failed
Bit 1: VerifyFail, Erase Verify Status
       0 = pass, all pages are in proper erased state
       1 = fail, at least one out of the 32 pages is not properly erased
Bit 6: MapRAMFail, MapRAM Status, Data Flash sector only
       0 = pass, MapRAM and Spare Page pass
       1 = fail, mapped pages, or invalid Spare Page, or MapRAM ECC fail
Bit 7: ExecFail, Execution status
       0 = pass, routine executed successfully
       1 = fail, routine failed to execute, due to invalid address, or assembly buffer open, or nested call

Example

This example verifies the erased state of the data flash sector after bootup.

void main(void)
{
(void)WDT1_Service();
if ( res.bit.GlobFail != 0 )
{
...sector is most probably not erased
}
else
{
...write new data to an erased sector
}
}

◆ USER_ERASEPG

uint8(*const USER_ERASEPG) (const uint32 *NVMPageAddr, const uint8 XRAM_RTNE_BRNCHNG)

Erases a flash page, for code flash as well as data flash.

Parameters
NVMPageAddrlogical address to the flash page, the address has to be page aligned (128byte aligned)
XRAM_RTNE_BRNCHNG0 = no RAM branch,
1 = RAM branch
Returns
uint8

Example

This example performs a page erase of the first data flash page.

void Example_Function(void)
{
uint8 res;
(void)WDT1_Service();
if ( ( res & 1 ) == 1 )
{
//erase failed
}
}

◆ USER_ERASEPG_VERIFY

uint8(*const USER_ERASEPG_VERIFY) (const uint32 page_addr)

This function performs a verify on an erased page.

This function checks if a given page is in proper erased state.

For the data flash sector it checks whether the Spare Page is in proper erased state,

regardless of the provided page address. Because in the Data Flash the Spare Page is

the next physical page being used for writing.

Note
BF-Step only.
Parameters
page_addraddress of the page which will be verified
Returns
uint8 (see TUser_ERASEPG_VERIFY)
Bit 0: GlobFail, function status, OR'd all flags
       0 = pass, sector erase verify successful
       1 = fail, sector erase verify failed
Bit 1: VerifyFail, Erase Verify Status
       0 = pass, all pages are in proper erased state
       1 = fail, at least one out of the 32 pages is not properly erased
Bit 6: MapRAMFail, MapRAM Status, Data Flash sector only
       0 = pass, MapRAM and Spare Page pass
       1 = fail, mapped pages, or invalid Spare Page, or MapRAM ECC fail
Bit 7: ExecFail, Execution status
       0 = pass, routine executed successfully
       1 = fail, routine failed to execute, due to invalid address, or assembly buffer open, or nested call

Example

This example verifies the erased state of the Spare Page of the data flash sector after bootup.

void main(void)
{
(void)WDT1_Service();
if ( res.bit.GlobFail != 0 )
{
...Spare Page not properly erased, perform a device reset to run the ServiceAlgorithm
}
else
{
...write new data to the data flash
}
}

◆ USER_MAPRAM_INIT

uint8(*const USER_MAPRAM_INIT) (void)

This function performs a MapRAM reinitialization.

The MapRAM is the logic to physical address translation for the data flash.

This function invalidates the MapRAM content and rebuilds from the data flash content.

It furthermore checks the mapping integrity, in case the mapping is not unambiguous an error will be reported.

in this case the data flash cannot be used until the error is solved.

This function also randomizes the Spare Page newly.

Returns
uint8
Bit 0: function status, OR'd all flags
       0 = pass, MapRAM initialized, no fails, data flash ready
       1 = fail, see bits[5:7] for further details
Bit 5: Double Mapping status
       0 = pass, no double-mapping found
       1 = fail, initialization failed due to double-mapping
Bit 6: faulty Page status
       0 = pass, no faulty page found
       1 = fail, initialization failed due to faulty page
Bit 7: Execution status
       0 = pass, routine executed successfully
       1 = fail, routine failed to execute

Example

This example performs a MapRAM initialization.

void main(void)
{
(void)WDT1_Service();
if ( res.bit.GlobFail == 1 )
{
//at least one fail occurred during MapRAM init
if ( ( res.bit.DoubleMapping == 1 ) ||
( res.bit.FaultyPage == 1 ) )
{
//restart the device to let ServiceAlgorithm try to fix the issue
}
if ( res.bit.ExecFail == 1 )
{
//ensure that this function is only called if no other NVM operation
//is ongoing. Close the assembly buffer, in case it is open and restart
//the MAPRAM initialization again.
}
}
}

◆ USER_NVM_CONFIG

bool(*const USER_NVM_CONFIG) (const uint8 *NVMSize, const uint8 *MapRAMSize)

Reads the total size of code flash and total size of data flash for this device.

Parameters
*NVMSizea pointer to a variable where the code flash size will be stored
*MapRAMSizea pointer to a variable where the data flash size will be stored
Return values
true= successful
false= failed

Example

This example performs read of the NVM configuration.

void Example_Function(void)
{
uint8 code_flash_size;
uint8 data_flash_size;
if ( USER_NVM_CONFIG( &code_flash_size, &data_flash_size) == true )
{
//code_flash_size and data_flash_size are valid
}
(void)WDT1_Service();
}

◆ USER_NVM_ECC2ADDR

uint8(*const USER_NVM_ECC2ADDR) (const uint16 *ecc2addr)

This function returns the last NVM address causing a double bit ECC failure.

Parameters
*ecc2addra pointer to a variable where the last double bit ECC failing address will be stored
Returns
uint8
Bit 0: ECC Double Bit error detection status
       0 = no NVM double bit error found
       1 = NVM double bit error detected
Bit 7: Execution status
       0 = pass, routine executed successfully, Bit0 valid
       1 = fail, routine failed to execute

Example

This example performs read of the NVM Double Bit ECC fail location.

static uint32 ecc_addr;
void NMI_Handler(void)
{
if ( NMI_ECC_Sts() == 1 )
{
if ( USER_NVM_ECC2ADDR( &ecc_addr ) == 1 )
{
//ecc_addr valid
}
}
}

◆ USER_NVM_ECC_CHECK

uint8(*const USER_NVM_ECC_CHECK) (void)

This function performs a ECC check on the entire NVM by reading the same.

This function does not alter any NVM content.

Returns
uint8
Bit 0: single bit errors (SBE)
       0 = pass, no SBEs detected
       1 = fail, at least one SBE detected
Bit 1: Double bit errors (DBE)
       0 = pass, no DBEs detected
       1 = fail, at least one DBE detected
Bit 7: Execution status
       0 = pass, routine executed successfully
       1 = fail, routine failed to execute, due to nested call

Example

This example performs a ECC check on the entire flash.

void Example_Function(void)
{
TUser_ECC_Check res_addr;
uint32 fail_addr;
res_check.reg = USER_NVM_ECC_CHECK();
(void)WDT1_Service();
if ( res_check.bit.SBE == 1 )
{
//single bit error, will be corrected during runtime
}
else if ( res_check.bit.DBE == 1 )
{
res_addr.reg = USER_ECC_CHECK( &fail_addr );
if ( res_addr.bit.SBE == 1)
{
//fail_addr points to a Single Bit Error
}
else if ( res_addr.bit.DBE == 1)
{
//fail_addr points to a Double Bit Error
}
else if ( res_addr.bit.ExecFail == 1)
{
//fail_addr not valid, function could not be executed
}
else
{
//everything pass?? We should not get here
}
}
else if ( res_check.bit.ExecFail == 1)
{
//ECC check could not be performed
}
else
{
//everything pass
}
}

◆ USER_NVMRDY

bool(*const USER_NVMRDY) (void)

Returns the status of the NVM module.

This can be used in case of RAM Branch to check whether the NVM module

has finished its operation and a jump back to the BootROM should be done,

in order to finish the started NVM operation.

Return values
true= NVM module is ready (not busy)
false= NVM module is not yet ready (busy)

Example

This example performs a user action as long as the NVM module is busy.

void Example_Function(void)
{
do
{
...user code...
}
while ( USER_NVMRDY() == false );
}
Note
This example makes only sense if it is executed from RAM.

◆ USER_OPENAB

uint8(*const USER_OPENAB) (const uint32 NVMPAGEAddr)

Opens the assembly buffer for writing to a flash page, for code flash as well as data flash.

This function has to be called as a preparation for a flash programming by USER_PROG.

Parameters
NVMPAGEAddrlogical address to the flash page, the address has to be page aligned (128byte aligned)
Returns
uint8, see TUser_OpenAB

Example

This example performs a page programming to the first data flash page.

void Example_Function(void)
{
TUser_OpenAB openab_res;
(void)WDT1_Service();
if ( openab_res.bit.ExecFail == 1 )
{
//Assembly buffer is already open, or
//nested NVM operation
}
if ( openab_res.bit.ABFail == 1 )
{
//data flash write protected, or
//wrong NVMPAGEAddr address, not within flash range
}
}

◆ USER_PROG

uint8(*const USER_PROG) (const uint8 PROG_FLAG)

Writes the assembly buffer content to the flash page addressed by USER_OPENAB.

Precondition
The successful execution of USER_OPENAB is required.
Parameters
PROG_FLAGoptions to control the RAM branch and corrective action of the USER_PROG function
Returns
uint8, see TUser_Prog

Example

This example performs a page programming to the first data flash page.

void Example_Function(void)
{
TUser_OpenAB openab_res;
TUser_Prog prog_res;
TProgFlag flags;
uint8 i;
uint8 *pAddr;
(void)WDT1_Service();
if ( openab_res.bit.ExecFail == 1 )
{
//Assembly buffer is already open, or
//nested NVM operation
}
else if ( openab_res.bit.ABFail == 1 )
{
//data flash write protected, or
//wrong NVMPAGEAddr address, not within flash range
}
else
{
//assembly buffer successfully opened
pAddr = (uint8*)DataFlashStart;
//fill assembly buffer with new data
for ( i = 0; i < FlashPageSize; i++)
{
pAddr[i] = i;
}
flags.bit.RAM_Branch = 0;
flags.bit.CorrAct = 1;
prog_res.reg = USER_PROG(flags.reg);
(void)WDT1_Service();
if (prog_res.bit.GlobFail == 1)
{
//handle fails
}
}
}

◆ USER_RAM_MBIST_START

uint8(*const USER_RAM_MBIST_START) (const uint16 RAM_MBIST_Stop_Addr, const uint16 RAM_MBIST_Start_addr)

This function performs a MBIST on the RAM for a given address range.

The RAM interface will be disabled for the duration of the MBIST,

accessing the RAM will not be possible for this time.

Warning
The RAM content for the selected range will be lost after the MBIST,
the RAM range will be initialized to '0'.
Parameters
RAM_MBIST_Stop_Addrend address for the MBIST, given as offset to RAMStart (0x18000000)
RAM_MBIST_Start_addrstarting address for the MBIST, given as offset to RAMStart (0x18000000)
Returns
uint8
Bit 0: function status, OR'd all flags
       0 = pass, MBIST ran pass
       1 = fail, MBIST failed
Bit 1: Address range failed
       0 = pass, address range good
       1 = fail, address out of range
Bit 7: Execution status
       0 = pass, routine executed successfully
       1 = fail, routine failed to execute, due to nested call

Example

This example performs a MBIST over the first half of the RAM.

void Example_Function(void)
{
uint8 res;
res = USER_RAM_MBIST_START((uint16)(RAMSize >> 1u), 0);
(void)WDT1_Service();
if ( res != 0 )
{
...any fail has happened
}
}

◆ USER_READ_100TP

bool(*const USER_READ_100TP) (const uint8 OTP_Page_Sel, const uint8 DataOffset, const uint32 *HundredTPData)

This function reads four bytes from a selected 100TP page.

Parameters
OTP_Page_Selselects one out of eight 100TP pages, 0x11 is page 1, 0x12 is page 2, ..., 0x18 is page 8
DataOffsetthe offset within the selected page, starting from value 0x00 to 0x7F
*HundredTPDataa pointer to a variable where the four bytes from the 100TP will be stored
Return values
true= pass
false= fail

Example

This example performs a complete read of the first 100TP page.

void Example_Function(void)
{
uint32 ui32;
uint8 page_data[128];
uint8 i;
for ( i = 0; i < FlashPageSize; i++ )
{
if ( USER_READ_100TP( 0x11, i, &ui32 ) == true )
{
page_data[i] = ui32 & 0xFF;
}
}
}

◆ USER_READ_CAL

uint8(*const USER_READ_CAL) (const uint8 NumOfBytes, const uint8 CSAddr, const uint16 RAMAddr)

Reads the NVM calibration data.

Parameters
NumOfBytesNumber of Bytes to be copied from config sector into the RAM (allowed values are form 01H to 80H).
CSAddr100TP page to take data from, 0x11 is page 1, 0x12 is page 2, ..., 0x18 is page 8
RAMAddrRAM address offset to copy data to (03FFH < RAMAddr < RAMAddr + NumOfBytes < RAM size).
Returns
uint8
Bit 0: Pass or Fail
       0 = Read is successful
       1 = Read is not successful due to invalid input values
Bit 7: Execution Pass/Fail status
       0 = Pass: Routine was correctly executed
       1 = Fail: Routine was not executed

Example

This example reads 16 bytes from 100TP page 1 at offset 0 and stores them in an array.

void Example_Function(void)
{
uint8 cal_data[0x20] = {0};
uint32 ramaddress = (uint32)cal_data;
uint16 ramoffset = ramaddress - 0x18000000;
USER_READ_CAL(0x10, 0x11, ramoffset);
}

◆ USER_VERIFY_PAGE

uint8(*const USER_VERIFY_PAGE) (const uint32 page_addr)

This function performs a verify on a programmed page.

This function checks if a given page whether the content has a proper data integrity.

Note
BF-Step only.
Parameters
page_addraddress of the page which will be verified
Returns
uint8 (see TUser_VERIFY_PAGE)
Bit 0: GlobFail, function status, OR'd all flags
       0 = pass, sector erase verify successful
       1 = fail, sector erase verify failed
Bit 1: VerifyFail, Erase Verify Status
       0 = pass, all pages are in proper erased state
       1 = fail, at least one out of the 32 pages is not properly erased
Bit 6: MapRAMFail, MapRAM Status, Data Flash sector only
       0 = pass, MapRAM and Spare Page pass
       1 = fail, mapped pages, or invalid Spare Page, or MapRAM ECC fail
Bit 7: ExecFail, Execution status
       0 = pass, routine executed successfully
       1 = fail, routine failed to execute, due to invalid address, or assembly buffer open, or nested call

Example

This example verifies the data integrity of the 1st page of the data flash sector after bootup.

void main(void)
{
(void)WDT1_Service();
if ( res.bit.GlobFail != 0 )
{
...page was potentially not properly written,
data should be read (if possible), then erase page and
program it again
!!! Ensure that erase/programming will not be interrupted !!!
}
else
{
... page data integrity given
}
}
TProgFlag
This struct defines the option flag for the USER_PROG function.
Definition: bootrom.h:220
TUser_OpenAB::ExecFail
uint8 ExecFail
Definition: bootrom.h:261
TProgFlag::reg
uint8 reg
Definition: bootrom.h:222
TUser_NVM_ECC_Check::ExecFail
uint8 ExecFail
Definition: bootrom.h:296
TProgFlag::CorrAct
uint8 CorrAct
Definition: bootrom.h:226
TUser_100TP_Prog::reg
uint8 reg
Definition: bootrom.h:204
TUser_OpenAB::ABFail
uint8 ABFail
Definition: bootrom.h:259
USER_ABORTPROG
bool(*const USER_ABORTPROG)(void)
Closes the Assembly Buffer.
TUser_Prog::bit
struct TUser_Prog::@713 bit
USER_CFLASH_RD_PROT_DIS
bool(*const USER_CFLASH_RD_PROT_DIS)(uint16 cflash_pw)
Removes the temporary code flash read protection. The password is compared against the.
WDT1_Service
bool WDT1_Service(void)
Services the WDT1 in the open window.
TUser_ERASEPG_VERIFY::GlobFail
uint8 GlobFail
Definition: bootrom.h:345
TUser_MAPRAM_Init::reg
uint8 reg
Definition: bootrom.h:272
USER_DFLASH_WR_PROT_DIS
bool(*const USER_DFLASH_WR_PROT_DIS)(uint16 dflash_pw)
Removes the temporary data flash write protection. The password is compared against the.
TUser_ERASEPG_VERIFY::bit
struct TUser_ERASEPG_VERIFY::@719 bit
TUser_MAPRAM_Init::GlobFail
uint8 GlobFail
Definition: bootrom.h:275
TUser_NVM_ECC_Check::SBE
uint8 SBE
Definition: bootrom.h:293
USER_NVMRDY
bool(*const USER_NVMRDY)(void)
Returns the status of the NVM module.
TUser_Prog
This union defines the return value of USER_PROG.
Definition: bootrom.h:235
TUser_ECC_Check::ExecFail
uint8 ExecFail
Definition: bootrom.h:313
TProgFlag::RAM_Branch
uint8 RAM_Branch
Definition: bootrom.h:225
USER_ECC_CHECK
uint8(*const USER_ECC_CHECK)(const uint32 *ecc2addr)
This function returns the address of the last ECC fail.
TUser_ERASE_SECTOR_VERIFY::bit
struct TUser_ERASE_SECTOR_VERIFY::@718 bit
NMI_Handler
void NMI_Handler(void)
The NMI_Handler checks which interrupt caused the call of the node handler (interrupt enabled and sta...
TUser_Prog::GlobFail
uint8 GlobFail
Definition: bootrom.h:240
USER_MAPRAM_INIT
uint8(*const USER_MAPRAM_INIT)(void)
This function performs a MapRAM reinitialization.
TUser_MAPRAM_Init::DoubleMapping
uint8 DoubleMapping
Definition: bootrom.h:277
TCustomerID
This union defines the return parameter of GetCustomerID.
Definition: bootrom.h:166
uint16
unsigned short uint16
16 bit unsigned value
Definition: types.h:140
USER_VERIFY_PAGE
uint8(*const USER_VERIFY_PAGE)(const uint32 page_addr)
This function performs a verify on a programmed page.
RAMSize
#define RAMSize
Definition: tle_variants.h:155
TUser_ERASEPG_VERIFY::reg
uint8 reg
Definition: bootrom.h:342
USER_CFLASH_RD_PROT_EN
bool(*const USER_CFLASH_RD_PROT_EN)(uint16 cflash_pw)
Sets the temporary code flash read protection. The password is compared against the.
USER_DFLASH_RD_PROT_DIS
bool(*const USER_DFLASH_RD_PROT_DIS)(uint16 dflash_pw)
Removes the temporary data flash read protection. The password is compared against the.
TUser_Prog::reg
uint8 reg
Definition: bootrom.h:237
DataFlashStart
#define DataFlashStart
Definition: tle_variants.h:181
TUser_ERASEPG_VERIFY
BF-Step only: This union defines the return value of USER_ERASEPG_VERIFY.
Definition: bootrom.h:340
TUser_VERIFY_PAGE::reg
uint8 reg
Definition: bootrom.h:360
TUser_NVM_ECC_Check
This union defines the return value of USER_NVM_ECC_CHECK.
Definition: bootrom.h:288
uint8
unsigned char uint8
8 bit unsigned value
Definition: types.h:139
USER_RAM_MBIST_START
uint8(*const USER_RAM_MBIST_START)(const uint16 RAM_MBIST_Stop_Addr, const uint16 RAM_MBIST_Start_addr)
This function performs a MBIST on the RAM for a given address range.
USER_NVM_ECC_CHECK
uint8(*const USER_NVM_ECC_CHECK)(void)
This function performs a ECC check on the entire NVM by reading the same.
TUser_100TP_Prog::GlobFail
uint8 GlobFail
Definition: bootrom.h:207
ProgramPage
uint8 ProgramPage(uint32 addr, const uint8 *buf, uint8 Branch, uint8 Correct, uint8 FailPageErase)
Programms a page to NVM.
TProgFlag::bit
struct TProgFlag::@712 bit
GetCustomerID
bool GetCustomerID(const TCustomerID *CustID)
Reads the Customer ID out of the 100TP NVM.
TUser_NVM_ECC_Check::DBE
uint8 DBE
Definition: bootrom.h:294
USER_ERASEPG
uint8(*const USER_ERASEPG)(const uint32 *NVMPageAddr, const uint8 XRAM_RTNE_BRNCHNG)
Erases a flash page, for code flash as well as data flash.
USER_ERASE_SECTOR_VERIFY
uint8(*const USER_ERASE_SECTOR_VERIFY)(const uint32 sector_addr)
This function performs a verify on an erased sector.
USER_DFLASH_RD_PROT_EN
bool(*const USER_DFLASH_RD_PROT_EN)(uint16 dflash_pw)
Sets the temporary data flash read protection. The password is compared against the.
uint32
unsigned int uint32
32 bit unsigned value
Definition: types.h:141
FlashPageSize
#define FlashPageSize
Definition: bootrom.h:126
TUser_MAPRAM_Init::ExecFail
uint8 ExecFail
Definition: bootrom.h:279
USER_ERASEPG_VERIFY
uint8(*const USER_ERASEPG_VERIFY)(const uint32 page_addr)
This function performs a verify on an erased page.
USER_CFLASH_WR_PROT_DIS
bool(*const USER_CFLASH_WR_PROT_DIS)(uint16 cflash_pw)
Removes the temporary code flash write protection. The password is compared against the.
TUser_OpenAB::reg
uint8 reg
Definition: bootrom.h:256
USER_NVM_CONFIG
bool(*const USER_NVM_CONFIG)(const uint8 *NVMSize, const uint8 *MapRAMSize)
Reads the total size of code flash and total size of data flash for this device.
USER_NVM_ECC2ADDR
uint8(*const USER_NVM_ECC2ADDR)(const uint16 *ecc2addr)
This function returns the last NVM address causing a double bit ECC failure.
TUser_ECC_Check::reg
uint8 reg
Definition: bootrom.h:307
USER_CFLASH_WR_PROT_EN
bool(*const USER_CFLASH_WR_PROT_EN)(uint16 cflash_pw)
Sets the temporary code flash write protection. The password is compared against the.
TUser_NVM_ECC_Check::reg
uint8 reg
Definition: bootrom.h:290
TUser_OpenAB::bit
struct TUser_OpenAB::@714 bit
USER_PROG
uint8(*const USER_PROG)(const uint8 PROG_FLAG)
Writes the assembly buffer content to the flash page addressed by USER_OPENAB.
TUser_VERIFY_PAGE::GlobFail
uint8 GlobFail
Definition: bootrom.h:363
TUser_ERASE_SECTOR_VERIFY::reg
uint8 reg
Definition: bootrom.h:324
USER_OPENAB
uint8(*const USER_OPENAB)(const uint32 NVMPAGEAddr)
Opens the assembly buffer for writing to a flash page, for code flash as well as data flash.
TUser_100TP_Prog
This union defines the return value of USER_100TP_PROG.
Definition: bootrom.h:202
TUser_ERASE_SECTOR_VERIFY::GlobFail
uint8 GlobFail
Definition: bootrom.h:327
TUser_100TP_Prog::bit
struct TUser_100TP_Prog::@711 bit
TUser_OpenAB
This union defines the return value of USER_OPENAB.
Definition: bootrom.h:254
TUser_MAPRAM_Init
This union defines the return value of USER_MAPRAM_INIT.
Definition: bootrom.h:270
TUser_VERIFY_PAGE
BF-Step only: This union defines the return value of USER_VERIFY_PAGE.
Definition: bootrom.h:358
TUser_ECC_Check::bit
struct TUser_ECC_Check::@717 bit
USER_DFLASH_WR_PROT_EN
bool(*const USER_DFLASH_WR_PROT_EN)(uint16 dflash_pw)
Sets the temporary data flash write protection. The password is compared against the.
WDT1_SOW_Service
void WDT1_SOW_Service(uint32 NoOfSOW)
Triggers a short-window (~30ms) of the WDT1.
TUser_VERIFY_PAGE::bit
struct TUser_VERIFY_PAGE::@720 bit
TUser_ECC_Check::SBE
uint8 SBE
Definition: bootrom.h:310
TUser_ECC_Check
This union defines the return value of USER_ECC_CHECK.
Definition: bootrom.h:305
USER_100TP_PROG
uint8(*const USER_100TP_PROG)(const uint8 OTP_Page_Sel)
This function writes data to a selected 100TP page.
USER_ERASE_SECTOR
uint8(*const USER_ERASE_SECTOR)(const uint32 NVMSectorAddr)
This function performs a sector erase.
TUser_ECC_Check::DBE
uint8 DBE
Definition: bootrom.h:311
TUser_MAPRAM_Init::FaultyPage
uint8 FaultyPage
Definition: bootrom.h:278
TUser_NVM_ECC_Check::bit
struct TUser_NVM_ECC_Check::@716 bit
TUser_ERASE_SECTOR_VERIFY
BF-Step only: This union defines the return value of USER_ERASE_SECTOR_VERIFY.
Definition: bootrom.h:322
TUser_MAPRAM_Init::bit
struct TUser_MAPRAM_Init::@715 bit
USER_READ_CAL
uint8(*const USER_READ_CAL)(const uint8 NumOfBytes, const uint8 CSAddr, const uint16 RAMAddr)
Reads the NVM calibration data.
USER_READ_100TP
bool(*const USER_READ_100TP)(const uint8 OTP_Page_Sel, const uint8 DataOffset, const uint32 *HundredTPData)
This function reads four bytes from a selected 100TP page.