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.

CCS/EK-TM4C1294XL: help with eeprom!!

Part Number: EK-TM4C1294XL

Tool/software: Code Composer Studio

extern void EEPROMRead(char *pui32Data, uint32_t ui32Address,
uint32_t ui32Count);


extern uint32_t EEPROMProgram(char *pui32Data,
uint32_t ui32Address,
uint32_t ui32Count);

these are the two prototype mentioned and they are not working properly.

even without any error in code the controller enters into infinite loop at every rread instruction.

please help!!

  • Hello Rohan,

    You will need to provide more detail than what you have done so for us to be able to help at all, and also including the full source code for your program especially initializations would help us with supporting you.

    Please try and use the "Insert Code, Attack Files and More..." and then add your code with our Syntax Highlighter that appears as the "</>" button on the toolbar.

    Are any EEPROM API's working? What EEPROM are you using?
  • #include "driverlib/eeprom.h"
    uint32_t e2size,e2block;
    uint32_t ui32EEPROMInit, ui32EEPROMStatus;
    
    void main(){
    SysCtlPeripheralEnable(SYSCTL_PERIPH_EEPROM0);
    	while(!SysCtlPeripheralReady(SYSCTL_PERIPH_EEPROM0))
    		{
    		}
    	ui32EEPROMInit = EEPROMInit();
    		if(ui32EEPROMInit != EEPROM_INIT_OK)
    		{
    		while(1)
    		{
    		}
    		}
    	e2size = EEPROMSizeGet();
    	e2block = EEPROMBlockCountGet();
    	//print(1, e2size, "", 1,0);
    	UARTprintf("EEPROM Size %d bytes\n", e2size);
    	UARTprintf("EEPROM Block Count: %d\n", e2block);
    char *textToWrite= "ABCD";
    ui32EEPROMStatus = EEPROMProgram(textToWrite, 0x400, 32);
        		while (ui32EEPROMStatus == EEPROM_RC_WORKING)
        		{
        		}
    char* text to read;
    EEPROMRead(read, 0x400, 160);
    
    while(1)
    {
    }
    }

    i'm providing u the jist of the program basically i want to send some data to the internal eeprom of the mcu and retrive the data when required but when ever the controller reaches to the "Read" instruction the mcu stops at the place into an infinite loop.

    unlike everyones basic code for controlling the eeprom, in the api that i have over my version of ccs in eeprom.h file are:

    extern void EEPROMRead(char *pui32Data, uint32_t ui32Address,
    uint32_t ui32Count);


    extern uint32_t EEPROMProgram(char *pui32Data,
    uint32_t ui32Address,
    uint32_t ui32Count);

    thank you!!

  • Rohan Parvatiyar said:
    unlike everyone's basic code for controlling the eeprom, in the api that i have over my version of ccs

    Would you not, "Speed, Ease & Enhance" this vendor's efforts - by presenting that,  "everyone's basic code" -  right here - so that it may be,  "Efficiently COMPARED & CONTRASTED" against your code - which is not (yet) succeeding?

    Easing your "helper's" job - works (very) much to your advantage...

  • #include <stdint.h>
    #include <stdbool.h>
    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "inc/hw_gpio.h"
    #include "inc/hw_ints.h"
    #include "driverlib/gpio.h"
    #include "driverlib/rom.h"
    #include "driverlib/rom_map.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/eeprom.h"
    #include "utils/uartstdio.h"
    #include "drivers/pinout.h"
    
    /**************************************************************************************
    *
    * Variables
    *
    * ************************************************************************************
    */
    
    #define E2PROM_TEST_ADDRESS 0x0000
    
    /*************************************************************************************************************
    * main.c
    **************************************************************************************************/
    
    int main(void) {
    uint32_t e2size,e2block;
    uint32_t ui32SysClock;
    uint32_t ui32EEPROMInit, ui32EEPROMStatus;
    
    // Data Variables and address
    uint32_t pui32Data[2];
    uint32_t pui32Read[2];
    
    
    //******************************SET CPU CLOCK AT 120 MHZ***********************************************************************************************//
    // Run from the PLL at 120 MHz.
    //
    
    ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
    SYSCTL_OSC_MAIN |
    SYSCTL_USE_PLL |
    SYSCTL_CFG_VCO_480), 120000000);
    
    
    //******************************ENABLE SYSTEM CLOCK FOR ON BOARD LED***********************************************************************************************//
    // Enable the GPIO port that is used for the on-board LED.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
    
    
    // Check if the peripheral access is enabled.
    
    while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPION))
    {
    }
    //
    // Turn off the LED.
    //
    GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, 0x0);
    // Enable the GPIO pin for the LED (PN0). Set the direction as output, and
    // enable the GPIO pin for digital function.
    
    GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_0);
    SysCtlDelay(20000);
    
    // Turn on board LED
    
    GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, GPIO_PIN_0);
    //******************************INITIALIZE UART***********************************************************************************************//
    
    /* EEPROM SETTINGS */
    SysCtlPeripheralEnable(SYSCTL_PERIPH_EEPROM0); // EEPROM activate
    //
    // Wait for the EEPROM module to be ready.
    //
    while(!SysCtlPeripheralReady(SYSCTL_PERIPH_EEPROM0))
    {
    }
    
    // Wait for the EEPROM Initialization to complete
    
    ui32EEPROMInit = EEPROMInit();
    
    //
    // Check if the EEPROM Initialization returned an error
    // and inform the application
    //
    if(ui32EEPROMInit != EEPROM_INIT_OK)
    {
    while(1)
    {
    }
    }
    
    /* UART SETTINGS */
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    GPIOPinConfigure(GPIO_PA0_U0RX);
    GPIOPinConfigure(GPIO_PA1_U0TX);
    GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    UARTStdioConfig(0, 115200, ui32SysClock);
    
    /***************Main Action ****************/
    
    UARTprintf("EEPROM Test Program \r\n");
    
    
    e2size = EEPROMSizeGet(); // Get EEPROM Size
    UARTprintf("EEPROM Size %d bytes\n", e2size);
    
    e2block = EEPROMBlockCountGet(); // Get EEPROM Block Count
    UARTprintf("EEPROM Block Count: %d\n", e2block);
    
    //*** Test Section***********************************************/
    // Program some data into the EEPROM at address 0x0000.
    // Calculate size of EEPROM and number of Blocks in that size
    pui32Data[0] = 0xFFFFFFFF;
    pui32Data[1] = 0x00000000;
    // wait for programming to be over
    ui32EEPROMStatus = EEPROMProgram(pui32Data, 0x400, sizeof(pui32Data));
    while (ui32EEPROMStatus == EEPROM_RC_WORKING){
    }
    UARTprintf("Data Written to EEPROM: %d\n", pui32Data);
    //
    // Read it back.
    //Do not attempt to read if a write is in progress
    if (ui32EEPROMStatus != EEPROM_RC_WRBUSY)
    EEPROMRead(pui32Read, 0x400, sizeof(pui32Read));
    
    UARTprintf("Data read from EEPROM: %d\n", pui32Read);
    
    int i =0,j=0;
    /********************************************************************************************************
    // For whole EEPROM: Number of iterations = EEPROMSIZE/NUMBER OF EEPROMBLOCKS :j<(e2size/e2block)
    // Calculation is as follows:
    // inner loop always traverses each block
    // Outer loop is responsible for correct offset into each block from start address
    // First block: j=0l; so inner loop goes from 0 to 95 location
    // Second iteration of inner loop :j is 1(outer loop) and so we traverse locations 96 onwards to 192..
    **********************************************************************************************************/
    for (j=0;j<(e2size/e2block);j++) {
    
    for (i=0;i<e2block;i++) {
    // One Block
    // wait for write to complete
    ui32EEPROMStatus = EEPROMProgram(pui32Data,(E2PROM_TEST_ADDRESS+i+j*e2block)
    , sizeof(pui32Data));
    while (ui32EEPROMStatus == EEPROM_RC_WORKING){
    } // wait for current program to complete
    //Do not attempt to read if a write is in progress
    ui32EEPROMStatus = EEPROMStatusGet();
    if (!ui32EEPROMStatus) // the EEDONE register is all zeroes if EEPROM is idle
    EEPROMRead(pui32Read, (E2PROM_TEST_ADDRESS+i+j*e2block), sizeof(pui32Read));
    // UARTprintf(" Block %d : Location:,%d", j,i);
    // UARTprintf("Data read from EEPROM: %d\n", pui32Read);
    // UARTFlushTx(1); // wait for data to be flushed
    } // end inner loop for
    UARTprintf("Done Block EEPROM: %d\n", j);
    
    } // end out loop for
    
    UARTprintf("Done Whole EEPROM:\n");
    while (1)
    {
    
    }
    return 0;
    }

    so this will be the basic code that everyone else have...

    hope that this helps my helper to sort out my issue!!

    thank you!

  • And:

    • had you tried - that exact code - and if so - what were your results?
    • what did you change/alter - now that you've Listed "everyone's working code?"      Cannot you "color code your changes" - to the right side of the existing (everyone's) code - for speedy & eased  comparison?

    As earlier noted - such, "Side by Side" comparison - rather than (vast) up/down scrolling - greatly  eases "wear/tear" upon your (hapless) helper crüe...

    If you HAD run "everyone's code" - it would further assist - if you'd describe just "where and how" that  (everyone's) code,  "Failed your expectations."

    Your objective should be to make the,  "Identification of any differences in code" - along w/your  "highlighting"  of   "code error's onset" - as clear & easily recognizable, as possible.    Don't you agree?

  • int main(void) {
    uint32_t e2size,e2block;                
    uint32_t ui32SysClock;
    uint32_t ui32EEPROMInit, ui32EEPROMStatus;
    
    // Data Variables and address
    uint32_t pui32Data[2];           char *textToWrite = 'A';
    uint32_t pui32Read[2];           char *textToRead;
    pui32Data[0] = 0xFFFFFFFF;
    pui32Data[1] = 0x00000000;
    // wait for programming to be over
    ui32EEPROMStatus = EEPROMProgram(pui32Data, 0x400, sizeof(pui32Data));    ui32EEPROMStatus = ROM_EEPROMProgram(textToWrite, 0x400, 200);  
    while (ui32EEPROMStatus == EEPROM_RC_WORKING){
    }
    UARTprintf("Data Written to EEPROM: %d\n", pui32Data);
    //
    // Read it back.
    //Do not attempt to read if a write is in progress
    if (ui32EEPROMStatus != EEPROM_RC_WRBUSY)
    EEPROMRead(pui32Read, 0x400, sizeof(pui32Read));           EEPROMRead(read, 0x400, 200);
    
    

    i have written the changed codes on the very right side of everyone else's code. 

    thank you!!

  • Rohan wrote, "i have written the changed codes on the very right side of everyone else's code. "

    I see "4 instances" of (possible) code changes - in the "Apr 11, 12:04 posting" - just arrived. Is this the "full extent" of the changes you've made?

    It is past midnight in the U.S. midwest - I'm about "done." (Kat & Dog seek (some) company ... they (both) are studying "C"...)
  • thank you so much!!
    I found my solution just needed inspiration!!
  • Your SOLUTION will inspire MANY!     So Glad - and GOOD for YOU - your terrific persistence WAS rewarded.    (slight encouragement - & increased focus - was "all that was needed!"

    Now - if you'd be so good - clarify your "change/correction to "everyone's code" - so that "Less than everyone" may profit from your findings!   (i.e. those discovering - this thread...)

    Good Job!    (how good do you (now) feel - it was always clear that you were sufficiently smart - you needed (slightly) better focus - that's it.)

  • uint32_t bla[1], red[1];
    	bla[0] = 0xFFFFFFFF;
    	
        	ui32EEPROMStatus = ROM_EEPROMProgram(bla, 0x400, sizeof(bla));
        		while (ui32EEPROMStatus == EEPROM_RC_WORKING)
        		{
        		}
        		//*textToWrite++;
        		ROM_EEPROMRead(red, 0x400, sizeof(red));

    so this will be the rsult if you want to store an unsigned integer value into the internal eeprom and retrive it in the same way.

    just changed the EEPROMProgram with ROM_EEPROMProgram, and similar with EEPROMRead function to ROM_EEPROM.

  • (THAT) registers - at least to me - as "unexpected." Unless the "preface" ROM - as used here - does not make a call to the MCU's "Rom Resident code" - and (then) the "overlap" proves "disturbing." Just maybe a vendor agent can review - & confirm/advise...
  • Hello cb1,

    Indeed unexpected as the ROM call should not vary from the normal call.

    What isn't highlighted is that the variable passed into the API is no longer a char but a uint32_t. I suspect that tweak was also key in solving the issue. Also will note of the usage of sizeof() for the 3rd parameter passed in both API's which were formally hardcoded as another change.
  • GREAT Ralph - thank you - I'm "guiding" from 50K feet - your kind/type of "fine detail"- REALLY proves (extremely) useful...