5.6 main.c Modified Code
The main.c
template file has been edited as shown below. Some comments have been
removed.
/*
(c) 2018 Microchip Technology Inc. and its subsidiaries.
<See generated main.c file for additional copyright information.>
*/
#include "mcc_generated_files/mcc.h"
#include <util/delay.h>
#define LED_ON_OFF_DELAY 500
#define NUM_EE_VALUES 8
#define EE_ADR_START 8
eeprom_adr_t ee_address;
nvmctrl_status_t status;
volatile uint8_t RAMArray[NUM_EE_VALUES];
/*
Main application
*/
int main(void)
{
/* Initializes MCU, drivers and middleware */
SYSTEM_Initialize();
/* Declare loop variable */
uint8_t i;
if (!FLASH_Initialize()) {
ee_address = EE_ADR_START;
// Write EEPROM Data
for(i=0; i<NUM_EE_VALUES; i++){
status = FLASH_WriteEepromByte(ee_address, i);
ee_address++;
}
ee_address = EE_ADR_START;
// Read EEPROM Data
for(i=0; i<NUM_EE_VALUES; i++){
RAMArray[i] = FLASH_ReadEepromByte(ee_address);
ee_address++;
}
}
while (1){
PORTF.OUTTGL = PIN5_bm; // toggle PB5
_delay_ms(LED_ON_OFF_DELAY);
}
}
/**
End of File
*/