How to Read from 4kB Flash Data of ADuCM330

Hello!

We are using ADuCM330 in our project. Our questions are:

1: Is it possible to save some data ( in the form of matrix or float variables ) on flash 4kB data location and also access (read) this data time to time through the execution code.    

2:  In the hardware manual only WRITING and ERASING commands are mentioned for flash 4kB data. If READING data from flash 4kB data location is possible then can you share some example code of WRITING and READING data from 4kB flash data?

Parents
  • 0
    •  Analog Employees 
    on Jul 11, 2017 5:39 AM

    Hello,

     

    see example below

     

    unsigned int nData = 0x12345678;           
    unsigned int pData[2];

     

     FLASH_Word_Write(DataFlash_Base+0x100,nData);           
     FLASH_Word_Read(DataFlash_Base+0x100, pData);

     

    //====================================================================
    //      Flash write 64bits
    //====================================================================
    FLASH_RESULT_TYPE FLASH_Word_Write ( int nAddress, int pData )
    {
        volatile unsigned int uiSTA;         // Variable for FEESTA

        FEEADR = nAddress;
        FEEDATL = pData;
        FEEDATH = pData;
        // FEEDAT2 = (unsigned char)Data00ToWrite32BitReg;    // ECC location, write also for endurance testing.

        FEECMD = FLSH_WRITE;             // Write to the FLASH
        do{
             do{
               uiSTA = FEESTA;
            }while(uiSTA & CMD_BUSY);
        }while(!(uiSTA & CMD_COMPLETE));

        if((uiSTA == 0x04)||(uiSTA == 0x0C))     // completed
        {
            return FLASH_SUCCESS;
        }
          else
        {
            return FLASH_ERROR;
        }
    }

     

    /*************************************************************************************************/
    /* Read a 64bit data word from Flash. Takes word aligned address and returns via pointer     */
    /*************************************************************************************************/
    void FLASH_Word_Read (unsigned int nAddress, unsigned int *pData )
    {
        unsigned int *pFlash        = 0;
     
        pFlash = (unsigned int *)nAddress;

        *(pData) = *(pFlash);
        *(++pData ) = *(++pFlash);

    }

     

     

    I hope this helps
    regards

    Holger

Reply
  • 0
    •  Analog Employees 
    on Jul 11, 2017 5:39 AM

    Hello,

     

    see example below

     

    unsigned int nData = 0x12345678;           
    unsigned int pData[2];

     

     FLASH_Word_Write(DataFlash_Base+0x100,nData);           
     FLASH_Word_Read(DataFlash_Base+0x100, pData);

     

    //====================================================================
    //      Flash write 64bits
    //====================================================================
    FLASH_RESULT_TYPE FLASH_Word_Write ( int nAddress, int pData )
    {
        volatile unsigned int uiSTA;         // Variable for FEESTA

        FEEADR = nAddress;
        FEEDATL = pData;
        FEEDATH = pData;
        // FEEDAT2 = (unsigned char)Data00ToWrite32BitReg;    // ECC location, write also for endurance testing.

        FEECMD = FLSH_WRITE;             // Write to the FLASH
        do{
             do{
               uiSTA = FEESTA;
            }while(uiSTA & CMD_BUSY);
        }while(!(uiSTA & CMD_COMPLETE));

        if((uiSTA == 0x04)||(uiSTA == 0x0C))     // completed
        {
            return FLASH_SUCCESS;
        }
          else
        {
            return FLASH_ERROR;
        }
    }

     

    /*************************************************************************************************/
    /* Read a 64bit data word from Flash. Takes word aligned address and returns via pointer     */
    /*************************************************************************************************/
    void FLASH_Word_Read (unsigned int nAddress, unsigned int *pData )
    {
        unsigned int *pFlash        = 0;
     
        pFlash = (unsigned int *)nAddress;

        *(pData) = *(pFlash);
        *(++pData ) = *(++pFlash);

    }

     

     

    I hope this helps
    regards

    Holger

Children
No Data