3.6.4 Example Functions

RAM Execution Disable/Locking Functions has some example functions for disabling and locking RAM execution and functions to verify that the disable and lock operations happened correctly. These can be added to various use cases to control RAM execution.

RAM Execution Disable/Locking Functions

#include <stdbool.h>

/**
 * @brief Disables execution from RAM.
 * @return none
 */
void RAM_EXECUTION_Disable(void) {
    BMXIRAML = BMXIRAMH;
}

/**
 * @brief Specifies if RAM execution is currently disabled
 * @return bool - true if RAM execution is currently disabled
 */
bool RAM_EXECUTION_IsDisabled(void) {
    return (BMXIRAML >= BMXIRAMH);
}

/**
 * @brief Locks the RAM execution address registers until reset.
 * @return none
 */
void RAM_EXECUTION_Lock(void) {
    PACCON1bits.BMXIRAMLLK = 1U;
    PACCON1bits.BMXIRAMHLK = 1U;
}

/**
 * @brief Specifies if RAM execution registers are locked until reset
 * @return bool - true if RAM execution registers are locked until reset
 */
bool RAM_EXECUTION_IsLocked(void) {
    return (PACCON1bits.BMXIRAMLLK == 1U) && (PACCON1bits.BMXIRAMHLK == 1U);
}