This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C1294KCPDT: EEPROM R/W delay?

Part Number: TM4C1294KCPDT
Other Parts Discussed in Thread: EK-TM4C1294XL, TM4C1294NCPDT

I run into some issue with eeprom in 1294. To simplify reading, I recreate the problem with the simple hello world program with a few added lines to R/W eeprom.

From a previous discussion on eeprom (), I didn't notice any delay when accessing EEPROM, but if I don't add huge delay, my test program falls into the second "oops" trap all the time.

Any guideline to check the readiness of eeprom? or maybe I missed something important?

Thanks!

//*****************************************************************************
//
// hello.c - Simple hello world example.
//
// Copyright (c) 2013-2014 Texas Instruments Incorporated. All rights reserved.
// Software License Agreement
//
// Texas Instruments (TI) is supplying this software for use solely and
// exclusively on TI's microcontroller products. The software is owned by
// TI and/or its suppliers, and is protected under applicable copyright
// laws. You may not combine this software with "viral" open-source
// software in order to form a larger program.
//
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
// DAMAGES, FOR ANY REASON WHATSOEVER.
//
// This is part of revision 2.1.0.12573 of the EK-TM4C1294XL Firmware Package.
//
//*****************************************************************************

#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "drivers/pinout.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"
#include "driverlib/eeprom.h"

#define SPECIAL_CODE 0xa5a55a5a

struct EEPROM_STRUCT{
// parameters saved in flash for data acquisition
uint32_t special_code; //1 int32
uint32_t channelScanlist[16]; //17
uint32_t rdled_flag; //18 record led flag
uint32_t quiet_flag; //19
uint32_t return_flag; //20 start recording flag command rd
uint32_t reserved_flag; //21
uint32_t sample_rate; //22
uint32_t channels_enabled; //23
uint32_t digital_state; //24
uint32_t stop_start; //25
uint32_t record_state; //26 record state = 0 (no recording); = 1 (recording) = 2 (stop recording when return _flag = true)
uint32_t softRev; //27 software revision
uint32_t hardRev; //28 hardware revision
uint32_t adcMode; //29 Mux = 0 or Parallel = 1
uint32_t adcClock; //30 clock to adc sample timer
#ifdef REVG
int32_t adc_offset[8][8]; //94 offset for 8 channels and 8 ranges
int32_t adc_scale[8][8]; //158 positive gain factor for 8 channels and 8 ranges
int32_t pga[8]; //166 pga index for 8 analog channels
#else
int32_t adc_offset[8]; //38 offset for 8 channels
int32_t adc_scale[8]; //46 positive gain factor for 8 channels
#endif

uint32_t cdcModel; //47(167) model number example 2107; (xx) = number of int32 total memory
uint32_t libModel; //48(168) model number example 2108; (xx) = number of int32 total memory
uint32_t model_n; //model number example 2108
uint32_t trialCount; //49(169) trial count

char key[32]; //57(177) adding 32 char or 8 uint32_t
char serial_n[32]; //65(185)
char lastCalDate[32]; //73(193)
char file_name[32]; //81(201)
char userID[32]; //89(209)
uint32_t cdcflag; //90(210) cdcflg = 1 for bulk, cdcflg = 0 for cdc mode
//total size of eeprom = 1537
#ifdef REVG
uint32_t reserved[1326]; //1536 - 210 = 1326
#else
//uint32_t reserved[2]; //1536 - 90 = 1446
#endif

};

//*****************************************************************************
//
//! \addtogroup example_list
//! <h1>Hello World (hello)</h1>
//!
//! A very simple ``hello world'' example. It simply displays ``Hello World!''
//! on the UART and is a starting point for more complicated applications.
//!
//! Open a terminal with 115,200 8-N-1 to see the output for this demo.
//
//*****************************************************************************

//*****************************************************************************
//
// System clock rate in Hz.
//
//*****************************************************************************
uint32_t g_ui32SysClock;

//*****************************************************************************
//
// The error routine that is called if the driver library encounters an error.
//
//*****************************************************************************
#ifdef DEBUG
void
__error__(char *pcFilename, uint32_t ui32Line)
{
}
#endif

//*****************************************************************************
//
// Configure the UART and its pins. This must be called before UARTprintf().
//
//*****************************************************************************
void
ConfigureUART(void)
{
//
// Enable the GPIO Peripheral used by the UART.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

//
// Enable UART0
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

//
// Configure GPIO Pins for UART mode.
//
ROM_GPIOPinConfigure(GPIO_PA0_U0RX);
ROM_GPIOPinConfigure(GPIO_PA1_U0TX);
ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

//
// Initialize the UART for console I/O.
//
UARTStdioConfig(0, 115200, g_ui32SysClock);
}

struct EEPROM_STRUCT eepromData;
#define PA1 0x12345678
#define PA2 0x87654321

//*****************************************************************************
//
// Print "Hello World!" to the UART on the Intelligent UART Module.
//
//*****************************************************************************
int
main(void)
{
int i, e2size, e2block;
//
// Run from the PLL at 120 MHz.
//
g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480), 120000000);

//
// Configure the device pins.
//
PinoutSet(false, false);

//
// Initialize the UART.
//
ConfigureUART();

//
// Hello!
//
UARTprintf("Hello, world!\n");

ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_EEPROM0);
SysCtlDelay(1000);
i=EEPROMInit();
UARTprintf("%d\n", i);
SysCtlDelay(1000);

EEPROMRead((uint32_t *)&eepromData, 0, sizeof(eepromData));
eepromData.special_code = PA1;
EEPROMProgram((uint32_t *)&eepromData, 0, sizeof(eepromData)); //reflash to init
SysCtlDelay(1000);
EEPROMRead((uint32_t *)&eepromData, 0, sizeof(eepromData));
if (eepromData.special_code != PA1){
UARTprintf("Ooops");
}

SysCtlDelay(1000);

eepromData.special_code = PA2;
EEPROMProgram((uint32_t *)&eepromData, 0, sizeof(eepromData)); //reflash to init
SysCtlDelay(100);
EEPROMRead((uint32_t *)&eepromData, 0, sizeof(eepromData));
if (eepromData.special_code != PA2){
UARTprintf("Ooops");
}
//
// Enable the GPIO pins for the LED D1 (PN1).
//
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_1);

//
// We are finished. Hang around flashing D1.
//
while(1)
{

}
}