Microchip® Advanced Software Framework

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NVM driver fuse and lock bits handling

Functions for reading fuses and writing lock bits.

The Fuses are used to set important system functions and can only be written from an external programming interface. The application software can read the fuses. The fuses are used to configure reset sources such as Brown-out Detector and Watchdog, Start-up configuration, JTAG enable and JTAG user ID.

The Lock bits are used to set protection level on the different flash sections. They are used to block read and/or write on the different flash sections. Lock bits can be written from en external programmer and from the application software to set a more strict protection level, but not to set a less strict protection level. Chip erase is the only way to erase the lock bits. The lock bits are erased after the rest of the flash memory is erased. An unprogrammed fuse or lock bit will have the value one, while a programmed fuse or lock bit will have the value zero. Both fuses and lock bits are reprogrammable like the Flash Program memory.

Note
The functions in this module are modifying the NVM.CMD register. If the application are using program space access in interrupts (__flash pointers in IAR EW or pgm_read_byte in GCC) interrupts needs to be disabled when running EEPROM access functions. If not the program space reads will be corrupted.

Enumerations

enum  fuse_byte_t {
  FUSEBYTE0 = 0,
  FUSEBYTE1 = 1,
  FUSEBYTE2 = 2,
  FUSEBYTE3 = 3,
  FUSEBYTE4 = 4,
  FUSEBYTE5 = 5
}
 

Functions

static void nvm_blba_lock_bits_write (enum NVM_BLBA_enum blba_lock)
 Program the BLBA lock bits. More...
 
static void nvm_blbat_lock_bits_write (enum NVM_BLBAT_enum blbat_lock)
 Program the BLBAT lock bits. More...
 
static void nvm_blbb_lock_bits_write (enum NVM_BLBB_enum blbb_lock)
 Program the BLBB lock bits. More...
 
uint8_t nvm_fuses_read (enum fuse_byte_t fuse)
 Read a fuse byte. More...
 
static void nvm_lb_lock_bits_write (enum NVM_LB_enum lb_lock)
 Program the LB lock bits. More...
 
static void nvm_lock_bits_write (enum NVM_BLBB_enum blbb_lock, enum NVM_BLBA_enum blba_lock, enum NVM_BLBAT_enum blbat_lock, enum NVM_LB_enum lb_lock)
 Program the lock bits. More...
 

Enumerator
FUSEBYTE0 
FUSEBYTE1 
FUSEBYTE2 
FUSEBYTE3 
FUSEBYTE4 
FUSEBYTE5 

static void nvm_blba_lock_bits_write ( enum NVM_BLBA_enum  blba_lock)
inlinestatic

Program the BLBA lock bits.

Program the lock bits for the application section (BLBA). Other lock bits (BLBB, BLBAT and LB) are not altered (ie. programmed to NOLOCK).

Parameters
blba_lockApplication section lock bits to program

References nvm_lock_bits_write().

Referenced by main().

static void nvm_blbat_lock_bits_write ( enum NVM_BLBAT_enum  blbat_lock)
inlinestatic

Program the BLBAT lock bits.

Program the lock bits for the application table section (BLBAT). Other lock bits (BLBB, BLBA and LB) are not altered (ie. programmed to NOLOCK).

Parameters
blbat_lockApplication table section lock bits to program

References nvm_lock_bits_write().

Referenced by main().

static void nvm_blbb_lock_bits_write ( enum NVM_BLBB_enum  blbb_lock)
inlinestatic

Program the BLBB lock bits.

Program the lock bits for the boot loader section (BLBB). Other lock bits (BLBA, BLBAT and LB) are not altered (ie. programmed to NOLOCK).

Parameters
blbb_lockBoot loader section lock bits to program

References nvm_lock_bits_write().

Referenced by main().

uint8_t nvm_fuses_read ( enum fuse_byte_t  fuse)

Read a fuse byte.

This function reads and returns the value of a given fuse byte.

Parameters
fuseFuse byte to read.
Returns
Byte value of fuse.

References nvm_issue_command(), and nvm_wait_until_ready().

Referenced by main().

static void nvm_lb_lock_bits_write ( enum NVM_LB_enum  lb_lock)
inlinestatic

Program the LB lock bits.

Program the lock bits for the flash and eeprom (LB). Other lock bits (BLBB, BLBA and BLBAT) are not altered (ie. programmed to NOLOCK).

Parameters
lb_lockFlash/eeprom lock bits to program

References nvm_lock_bits_write().

Referenced by main(), and nvm_set_security_bit().

static void nvm_lock_bits_write ( enum NVM_BLBB_enum  blbb_lock,
enum NVM_BLBA_enum  blba_lock,
enum NVM_BLBAT_enum  blbat_lock,
enum NVM_LB_enum  lb_lock 
)
inlinestatic

Program the lock bits.

Program the lock bits to the given values. Lock bits can only be programmed to a more secure setting than previously programmed. To clear lock bits, a flash erase has to be issued.

Parameters
blbb_lockBoot loader section lock bits to program
blba_lockApplication section lock bits to program
blbat_lockApplication table section lock bits to program
lb_lockFlash/eeprom lock bits to program

References nvm_issue_command(), and nvm_wait_until_ready().

Referenced by main(), nvm_blba_lock_bits_write(), nvm_blbat_lock_bits_write(), nvm_blbb_lock_bits_write(), and nvm_lb_lock_bits_write().