Microchip® Advanced Software Framework

flash_example.c File Reference

Example of flash access using the FLASHC driver.

Copyright (c) 2009-2018 Microchip Technology Inc. and its subsidiaries.

#include "compiler.h"
#include "print_funcs.h"
#include "board.h"
#include "power_clocks_lib.h"
#include "flashc.h"

Data Structures

struct  nvram_data_t
 Structure type containing variables to store in NVRAM using a specific memory map. More...
 

Functions

static void flash_rw_example (const char *caption, nvram_data_t *nvram_data)
 This is an example demonstrating flash read / write data accesses using the FLASHC driver. More...
 
int main (void)
 Main function running the example on both the flash array and the User page. More...
 
static void print_nvram_variables (nvram_data_t *nvram_data)
 Prints the variables stored in NVRAM. More...
 

Variables

static nvram_data_t flash_nvram_data
 NVRAM data structure located in the flash array. More...
 
static nvram_data_t user_nvram_data
 NVRAM data structure located in the User page. More...
 

static void flash_rw_example ( const char *  caption,
nvram_data_t nvram_data 
)
static

This is an example demonstrating flash read / write data accesses using the FLASHC driver.

Parameters
captionCaption to print before running the example.
nvram_dataPointer to the NVRAM data structure to use in the example.

References flashc_memcpy(), flashc_memset, print_dbg(), print_nvram_variables(), nvram_data_t::var16, nvram_data_t::var32, nvram_data_t::var8, and nvram_data_t::var8_3.

Referenced by main().

int main ( void  )

Main function running the example on both the flash array and the User page.

References flash_nvram_data, flash_rw_example(), FOSC0, init_dbg_rs232(), OSC0_STARTUP, PCL_OSC0, pcl_switch_to_osc(), and user_nvram_data.

static void print_nvram_variables ( nvram_data_t nvram_data)
static

Prints the variables stored in NVRAM.

Parameters
nvram_dataPointer to the NVRAM data structure to print.

References print_dbg(), print_dbg_char_hex(), print_dbg_hex(), print_dbg_short_hex(), nvram_data_t::var16, nvram_data_t::var32, nvram_data_t::var8, and nvram_data_t::var8_3.

Referenced by flash_rw_example().

nvram_data_t flash_nvram_data
static

NVRAM data structure located in the flash array.

Referenced by main().

nvram_data_t user_nvram_data
static

NVRAM data structure located in the User page.

Referenced by main().