Microchip® Advanced Software Framework

flash_example.c File Reference

Example of flash access using the FLASHCDW 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 "flashcdw.h"

Data Structures

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

Macros

#define EXAMPLE_TARGET_DFLL_FREQ_HZ   96000000
 
#define EXAMPLE_TARGET_MCUCLK_FREQ_HZ   12000000
 
#define EXAMPLE_TARGET_PBACLK_FREQ_HZ   12000000
 

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 FLASHCDW 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...
 
Parameters to pcl_configure_clocks().
static scif_gclk_opt_t gc_dfllif_ref_opt = { SCIF_GCCTRL_SLOWCLOCK, 0, false}
 
static pcl_freq_param_t pcl_dfll_freq_param
 

#define EXAMPLE_TARGET_DFLL_FREQ_HZ   96000000
#define EXAMPLE_TARGET_MCUCLK_FREQ_HZ   12000000
#define EXAMPLE_TARGET_PBACLK_FREQ_HZ   12000000

Referenced by main().

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 FLASHCDW driver.

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

References flashcdw_memcpy(), flashcdw_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().

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().

scif_gclk_opt_t gc_dfllif_ref_opt = { SCIF_GCCTRL_SLOWCLOCK, 0, false}
static
pcl_freq_param_t pcl_dfll_freq_param
static
Initial value:
= {
.main_clk_src = PCL_MC_DFLL0,
.pextra_params = &gc_dfllif_ref_opt
}
#define EXAMPLE_TARGET_PBACLK_FREQ_HZ
Definition: flash_example.c:99
Definition: power_clocks_lib.h:106
#define EXAMPLE_TARGET_MCUCLK_FREQ_HZ
Definition: flash_example.c:98
static scif_gclk_opt_t gc_dfllif_ref_opt
Definition: flash_example.c:103
#define EXAMPLE_TARGET_DFLL_FREQ_HZ
Definition: flash_example.c:97

Referenced by main().

nvram_data_t user_nvram_data
static

NVRAM data structure located in the User page.

Referenced by main().