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.

TMS570LS0914: FEE configuration and usage

Part Number: TMS570LS0914
Other Parts Discussed in Thread: HALCOGEN

Tool/software:

Hello,

I have configured FEE in 20 blocks. Out of which 16 blocks size is 64 bytes, block 17 to block 19 the size is 1024 bytes and block 20 has 256 bytes size.

FEE HALcogen configuration images are attached here with this query.

Issue : while writing with Write_Sync () returns OK , TI_Fee_GetStatus also returns IDLE, but TI_Fee_GetJobResult() function returns JOB_PENDING. 

because of this, I am not able to write next block.

This happens randomly at any block index.

Note: currently only 2 blocks are used out of 16 blocks, but 17-20 are in use.

Kindly help me to get resolve this.

             

  • Hi Prajacta,

    Have you called the Fee_Init() to initialize the EEPROM before issuing any read/write commands? The HAL GUI only supports 16 blocks, you need to add other blocks (17~20) manually in ti_fee_cfg.c. AFter adding the blocks, you must update the number of blocks to 20 (from 16).

    One error in your config GUI, the maximum virtual sector in your config should be 4 rather than 16.

  • Hello QJ Wang,

    Thank you for your response.

    Here, I can not edit the Max number of Virtual sectors. But Number of Virtual sectors I have defined 4.

    As you mentioned, Yes, block 17-20 I have added manually on ti_fee_cfg.c and required necessary changes.

     Fee_Init() also called in main before  periodic call of Write_Sync (). 

    One more thing, I have call Write_Sync () with periodicity of 1 sec. Can I decrease this further ? if yes, at which value ?

  • Hello,

    I found one more thing while investigating the issue is : Because of  TI_Fee_GlobalVariables[1].Fee_ModuleState = BUSY_INTERNAL, Block index not moving to next. This happens even to blank block writing (block 16).

    Please help . It's urgent.

  • Hi Prajakta,

    I wrote data to 2 EEPS using TI_Fee_WriteSync() and TI_Fee_WriteAsync(), both works fine.

    Two parameters should be changed (ti_fee_cfg.h)

    #define TI_FEE_NUMBER_OF_BLOCKS                             20U

    #define TI_FEE_TOTAL_BLOCKS_DATASETS                       20U

    Attached is my working project:

    1. 2 EEPS, each has 2 Virtual sectors

    2. Program 11 blocks to #1 EEPROM, and 9 block to #2 EEPROM with async method

    3. Program 11 blocks to #1 EEPROM, and 9 block to #2 EEPROM with sync method

    I don't have LS0914 test board, my code was tested on RM46Lx board. RM46Lx uses same FEE IP as on LS0914. The major difference between two devices is the endianness: LS0914 is a big endian device, and RM46 is a little endian device.

    https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/908/RM46_5F00_2FEE_5F00_Test.hcghttps://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/908/RM46_5F00_2FEE_5F00_Test.dil

    /*
     * main.c
     */
    #include "F021.h"
    #include "ti_fee.h"
    
    uint16 u16JobResult,Status;
    Std_ReturnType oResult=E_OK;
    
    uint8 SpecialRamBlock[128]; //block size is 64 bytes defined in HALCOGen
    
    void delay(void)
    {
        unsigned int dummycnt=0x0000FFU;
        do
        {
            dummycnt--;
        }
        while(dummycnt>0);
    }
    
    int main(void)
    {
    	unsigned int BlockOffset;
        unsigned int loop;
    
    
    	for(loop=0;loop<128;loop++)
    	    SpecialRamBlock[loop] = loop;
    
        TI_Fee_Init();
        do
        {
            TI_Fee_MainFunction();
            delay();
            Status=TI_Fee_GetStatus(0);
        }
        while(Status!=IDLE);
    
        for(loop=1; loop<21; loop++){
            TI_Fee_WriteAsync(loop, &SpecialRamBlock[loop]);
            do
            {
                TI_Fee_MainFunction();
                delay();
                Status=TI_Fee_GetStatus(0);
            }
            while(Status!=IDLE);
        }
    
        for(loop=1; loop<21; loop++){
            TI_Fee_WriteSync(loop, &SpecialRamBlock[loop+21]);
            do
            {
                TI_Fee_MainFunction();
                delay();
                Status=TI_Fee_GetStatus(0);
            }
            while(Status!=IDLE);
        }
    
    	return 0;
    }
    
    /** @file ti_fee_cfg.c 
    *   @brief FEE Driver Implementation File
    *   @date 11-Dec-2018
    *   @version 04.07.01
    *
    *   This is the FEE configuration parameter file.
    */
    
    /* 
    * Copyright (C) 2009-2018 Texas Instruments Incorporated - www.ti.com  
    * 
    * 
    *  Redistribution and use in source and binary forms, with or without 
    *  modification, are permitted provided that the following conditions 
    *  are met:
    *
    *    Redistributions of source code must retain the above copyright 
    *    notice, this list of conditions and the following disclaimer.
    *
    *    Redistributions in binary form must reproduce the above copyright
    *    notice, this list of conditions and the following disclaimer in the 
    *    documentation and/or other materials provided with the   
    *    distribution.
    *
    *    Neither the name of Texas Instruments Incorporated nor the names of
    *    its contributors may be used to endorse or promote products derived
    *    from this software without specific prior written permission.
    *
    *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    *
    */
    
    
    /* USER CODE BEGIN (0) */
    /* USER CODE END */
    
    /* Include Files                                                              */
    
    #include "ti_fee.h"
    
    
    
    /*----------------------------------------------------------------------------*/
    /* Fee Version Check                                                          */
    
     #if (TI_FEE_MAJOR_VERSION != 3U)
         #error TI_FEE_Cfg.c: TI_FEE_SW_MAJOR_VERSION of TI_FEE.h is incompatible.
     #endif /* FEE_SW_MAJOR_VERSION */
     #if (TI_FEE_MINOR_VERSION != 0U)
         #error TI_FEE_Cfg.c: TI_FEE_SW_MINOR_VERSION of TI_FEE.h is incompatible.
     #endif /* FEE_SW_MINOR_VERSION */
     #if (TI_FEE_PATCH_VERSION != 2U)
         #error TI_FEE_Cfg.c: TI_FEE_SW_PATCH_VERSION of TI_FEE.h is incompatible.
     #endif /* FEE_SW_PATCH_VERSION */
    
    /*SAFETYMCUSW 580 S MR:1.1 <APPROVED> "Reason - This is the format to use for specifying memorysections."*/
     #define FEE_START_SEC_CONST_UNSPECIFIED
     /*SAFETYMCUSW 338 S MR:19.1 <APPROVED> "Reason - This is the format to use for specifying memorysections."*/
    #include "MemMap.h" 
    
    /*----------------------------------------------------------------------------*/
    /* TI Fee Configurations                                                     */
    
    /** @struct Fee_VirtualSectorConfigType 	*/
    /*  @brief Virtual Sector Configuration 	*/
    const Fee_VirtualSectorConfigType Fee_VirtualSectorConfiguration[TI_FEE_NUMBER_OF_VIRTUAL_SECTORS] =
    {
    
        /* Virtual Sector 1 */
        {
           /* Virtual sector number */      1U,
           /* Bank                  */      7U,      
           /* Start Sector          */      (Fapi_FlashSectorType)0U,
           /* End Sector            */      (Fapi_FlashSectorType)0U
        },
        /* Virtual Sector 2 */
        {
            /* Virtual sector number */     2U,
            /* Bank                  */     7U,
            /* Start Sector          */     (Fapi_FlashSectorType)1U,            
    		/* End Sector            */     (Fapi_FlashSectorType)1U
        }
        ,
        /* Virtual Sector 3 */
        {
            /* Virtual sector number */     3U,
            /* Bank                  */     7U,     
            /* Start Sector          */     (Fapi_FlashSectorType)2U,
            /* End Sector            */     (Fapi_FlashSectorType)2U     
        }
        ,
        /* Virtual Sector 4 */
        {
            /* Virtual sector number */     4U,
            /* Bank                  */     7U,
            /* Start Sector          */     (Fapi_FlashSectorType)3U,
            /* End Sector            */     (Fapi_FlashSectorType)3U        
        }
      
    };
    
    
    /* Block Configurations         */
    /* SourceId : HL_Fee_SourceId_2 */
    /* DesignId : HL_FEE_DesignId_3, HL_FEE_DesignId_8 */
    /* Requirements : HL_FEE_SR2, HL_FEE_SR3, HL_FEE_SR4, HL_FEE_SR6, HL_FEE_SR85, HL_FEE_SR86
                      HL_FEE_SR87, HL_FEE_SR88, HL_FEE_SR89, HL_FEE_SR90, HL_FEE_SR91 */
    const Fee_BlockConfigType Fee_BlockConfiguration[TI_FEE_NUMBER_OF_BLOCKS] =
    {
            /*      Block 1 */
            {
                   /* Block number                          */     1U, 
                   /* Block size                            */     8U,
                   /* Block immediate data used             */     TRUE,			   
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,			   
                   /* EEP number                            */     0U			   
            }
    
            ,
            /*      Block 2 */
            {
                   /* Block number                          */     2U, 
                   /* Block size                            */     8U,
                   /* Block immediate data used             */     TRUE,			   
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,		   
                   /* EEP number                            */     0U			   
            }
            ,
            /*      Block 3 */
            {
                   /* Block number                          */     3U, 
                   /* Block size                            */     8U,
                   /* Block immediate data used             */     TRUE,			   
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,			   
                   /* EEP number                            */     0U			   
            }
            ,
            /*      Block 4 */
            {
                   /* Block number                          */     4U, 
                   /* Block size                            */     8U,
                   /* Block immediate data used             */     TRUE,			   
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,			   
                   /* EEP number                            */     0U			   
            }
            ,
            /*      Block 5 */
            {
                   /* Block number                          */     5U, 
                   /* Block size                            */     8U,
                   /* Block immediate data used             */     TRUE,			   
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,			   
                   /* EEP number                            */     0U			   
            }
            ,
            /*      Block 6 */
            {
                   /* Block number                          */     6U, 
                   /* Block size                            */     8U,
                   /* Block immediate data used             */     TRUE,			   
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,			   
                   /* EEP number                            */     0U			   
            }
            ,
            /*      Block 7 */
            {
                   /* Block number                          */     7U, 
                   /* Block size                            */     8U,
                   /* Block immediate data used             */     TRUE,			   
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,			   
                   /* EEP number                            */     0U			   
            }
            ,
            /*      Block 8 */
            {
                   /* Block number                          */     8U, 
                   /* Block size                            */     8U,
                   /* Block immediate data used             */     TRUE,			   
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,			   
                   /* EEP number                            */     0U			   
            }
            ,
            /*      Block 9 */
            {
                   /* Block number                          */     9U, 
                   /* Block size                            */     8U,
                   /* Block immediate data used             */     TRUE,			   
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,			   
                   /* EEP number                            */     0U			   
            }
            ,
            /*      Block 10 */
            {
                   /* Block number                          */     10U, 
                   /* Block size                            */     8U,
                   /* Block immediate data used             */     TRUE,			   
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,		   
                   /* EEP number                            */     0U			   
            }
            ,
            /*      Block 11 */
            {
                   /* Block number                          */     11U, 
                   /* Block size                            */     8U,
                   /* Block immediate data used             */     TRUE,			   
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,			   
                   /* EEP number                            */     0U			   
            }
            ,
            /*      Block 12 */
            {
                   /* Block number                          */     12U, 
                   /* Block size                            */     8U,
                   /* Block immediate data used             */     TRUE,			   
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,			   
                   /* EEP number                            */     1U			   
            }
            ,
            /*      Block 13 */
            {
                   /* Block number                          */     13U, 
                   /* Block size                            */     8U,
                   /* Block immediate data used             */     TRUE,			   
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,			   
                   /* EEP number                            */     1U			   
            }
            ,
            /*      Block 14 */
            {
                   /* Block number                          */     14U, 
                   /* Block size                            */     8U,
                   /* Block immediate data used             */     TRUE,			   
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,		   
                   /* EEP number                            */     1U			   
            }
            ,
            /*      Block 15 */
            {
                   /* Block number                          */     15U, 
                   /* Block size                            */     8U,
                   /* Block immediate data used             */     TRUE,			   
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,			   
                   /* EEP number                            */     1U			   
            }
            ,
            /*      Block 16 */
            {
                   /* Block number                          */     16U, 
                   /* Block size                            */     8U,
                   /* Block immediate data used             */     TRUE,			   
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,			   
                   /* EEP number                            */     1U			   
            }
    		,
            /*      Block 17 */
            {
                   /* Block number                          */     17U,
                   /* Block size                            */     16U,
                   /* Block immediate data used             */     TRUE,
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,
                   /* EEP number                            */     1U
            }
            ,
            /*      Block 18 */
            {
                   /* Block number                          */     18U,
                   /* Block size                            */     16U,
                   /* Block immediate data used             */     TRUE,
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,
                   /* EEP number                            */     1U
            }
            ,
            /*      Block 19 */
            {
                   /* Block number                          */     19U,
                   /* Block size                            */     16U,
                   /* Block immediate data used             */     TRUE,
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,
                   /* EEP number                            */     1U
            }
            ,
            /*      Block 20 */
            {
                   /* Block number                          */     20U,
                   /* Block size                            */     16U,
                   /* Block immediate data used             */     TRUE,
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,
                   /* EEP number                            */     1U
            }
            ,
    		/* If project needs more than 16 blocks, add additional blocks here and also 
               modify TI_FEE_TOTAL_BLOCKS_DATASETS and TI_FEE_NUMBER_OF_BLOCKS in ti_fee_cfg.h 	*/
    /* USER CODE BEGIN (1) */
    /* USER CODE END */
     
    };
    
    /*SAFETYMCUSW 580 S MR:1.1 <APPROVED> "Reason - This is the format to use for specifying memorysections."*/
    #define FEE_STOP_SEC_CONST_UNSPECIFIED
    /*SAFETYMCUSW 338 S MR:19.1 <APPROVED> "Reason - This is the format to use for specifying memorysections."*/
    #include "MemMap.h"
    
    /*----------------------------------------------------------------------------*/
    /* USER CODE BEGIN (2) */
    /* USER CODE END */
    
    6327.ti_fee_cfg.h

  • Hi QJ Wang,

    This code snippets helped me a lot. My issue of TI_Fee_GlobalVariables[1].Fee_ModuleState = BUSY_INTERNAL, resolved. Thanks for this.

    One more thing, I have call Write_Sync () with periodicity of 1 sec. Can I decrease this further ? if yes, at which value ?

    Also I have attached my wr and rd functions with this .please go through it once and correct me if I am wrong.

    ti_fee_cfg.c and ti_fee_cfg.h files also attached.

    0458.ti_fee_cfg.h 

    /***************************************************************************************************
    ** Function name    : NVMHand_Init
    **
    ** Description      : To initialize the FEE module and read the data into memory
    **
    ** Parameter index  : None
    **
    ** Return value     : None
    **
    ** Remarks          : None
    **
    ***************************************************************************************************/
    uint32_t NVMHand_Init(void)
    {
    	Std_ReturnType Uc_Result = (Std_ReturnType)E_OK;	/* Variable to hold the return value of read function */
    	TI_FeeJobResultType Enm_JobResult;					/* Variable to hold the last FEE operation result */
    	TI_FeeModuleStatusType Enm_Status;					/* Variable to hold the status of FEE */
    	uint16_t Us_CurrBlkIdx;								/* Variable to hold the block number */
    
    	/* Initialize the TI FEE. This will create Virtual sectors, initialize global variables etc.*/
    	TI_Fee_Init();
    
        /* Wait till the FEE is in IDLE State */
    	do
    	{
    		TI_Fee_MainFunction();
    		Delay_Us(100U); 		/* 100 micro sec*/
    		Enm_Status = TI_Fee_GetStatus(NVMHAND_0U);
    	} while (Enm_Status != IDLE);
    
    	/* Check and fix possible FEE initialization errors */
    	Uc_Result = (uint8_t)NVMHand_ManageError(0);
    
    	if (Uc_Result == (Std_ReturnType)E_OK)
    	{
    		for (Us_CurrBlkIdx = NVMHAND_0U; Us_CurrBlkIdx < TI_FEE_NUMBER_OF_BLOCKS; Us_CurrBlkIdx++)
    		{
    			/* Read block data into the respective buffer */
    			Uc_Result = TI_Fee_ReadSync((Us_CurrBlkIdx + NVMHAND_1U), NVMHAND_0U, St_ArrBlkInfo[Us_CurrBlkIdx].Ptr_BlkBuf, St_ArrBlkInfo[Us_CurrBlkIdx].Us_BlkSz);
    
    			do
    			{
    			    TI_Fee_MainFunction();
    			    Delay_Us(10U);		/* 10 micro sec*/
    
    			    Enm_Status = TI_Fee_GetStatus(NVMHAND_0U);
    
    			}while(Enm_Status != IDLE);
    
    			if (Uc_Result == (Std_ReturnType)E_OK)
    			{
    				Enm_JobResult = TI_Fee_GetJobResult(NVMHAND_0U);
    
    				if (Enm_JobResult == JOB_OK)
    				{
    					/* Copy NVM data into the respective data fields */
    					St_ArrBlkInfo[Us_CurrBlkIdx].Ptr_FnUpdtNVMReadBuf();
    				}
    				else
    				{
    					if (Enm_JobResult != BLOCK_INVALID)
    					{
    						/* Operation failed */
    						Uc_Result = (Std_ReturnType)E_NOT_OK;
    					}
    					else
    					{
    						St_ArrBlkInfo[Us_CurrBlkIdx].Ptr_FnSetdefaultvalue();
    					}
    				}
    			}
    
    			if (Uc_Result == (Std_ReturnType)E_NOT_OK)
    			{
    				break;
    			}
    		}
    	}
    
    
    	/* If all the blocks were successfully read, set the flag to commence write operation */
    	if (Us_CurrBlkIdx >= TI_FEE_NUMBER_OF_BLOCKS)
    	{
    		Ucs_WriteReq = NVMHAND_1U; 
    		NvmRd_Complete = TRUE;
    	}
    
    	return (uint32_t)Uc_Result;
    }
    
    /***************************************************************************************************
    ** Function name    : NVMHand_Write
    **
    ** Description      : write the data into memory
    **
    ** Parameter index  : None
    **
    ** Return value     : None
    **
    ** Remarks          : None
    **
    ***************************************************************************************************/
    uint32_t NVMHand_Write(uint32 NVM_WRITE)
    {
        Std_ReturnType Uc_Result = (Std_ReturnType)E_OK;		/* Variable to hold the return value of the write function */
        TI_FeeJobResultType Enm_JobResult;						/* Variable to hold the last job result */
        static uint16 Us_CurrBlkIdx = NVMHAND_0U;				/* Variable to hold the current block index */
        TI_FeeModuleStatusType Enm_Status;						/* Variable to hold the status of FEE */
        static Uc_BlkWrFailCnt = NVMHAND_0U;
    
        if (Ucs_WriteReq == NVMHAND_1U)
        {
            /* Update the RAM Buffer with the latest data */
            St_ArrBlkInfo[Us_CurrBlkIdx].Ptr_FnUpdtNVMWriteBuf();
    
            Ucs_WriteReq = NVMHAND_0U;
    
        }
        /* Set the FEE Bank (Bank 7) as the active bank */
        (void)Fapi_setActiveFlashBank(Fapi_FlashBank7);
    
        /* Write the block into the EEP Synchronously */
        Uc_Result = TI_Fee_WriteSync((Us_CurrBlkIdx + NVMHAND_1U), St_ArrBlkInfo[Us_CurrBlkIdx].Ptr_BlkBuf);
    
        do
        {
            TI_Fee_MainFunction();
            Delay_Us(10U);			/* 100 micro sec*/
    
            Enm_Status = TI_Fee_GetStatus(NVMHAND_0U);
    
        }while(Enm_Status != IDLE);
    
        if (Uc_Result == (Std_ReturnType)E_OK)
        {
            Enm_JobResult = TI_Fee_GetJobResult(NVMHAND_0U);
            if(Enm_JobResult != JOB_OK)
            {
                /* Operation failed */
                Uc_Result = (Std_ReturnType)E_NOT_OK;
            }
        }
        if(Uc_Result == (Std_ReturnType)E_NOT_OK)
        {
            Uc_BlkWrFailCnt++;
    
            if(Uc_BlkWrFailCnt >= 10u)
            {
    
            }
        }
    
        /* If the operation is successful, proceed to write the next block */
        if (Uc_Result == (Std_ReturnType)E_OK)
        {
            if((Us_CurrBlkIdx == (TI_FEE_NUMBER_OF_BLOCKS - NVMHAND_1U))&&(TRUE == SleepModeTriggered))
            {
                NVM_FCMAgingCntWrSucessful = TRUE;
             //   NVMHAND_WrBlkAvailable = 0;
            }
    
            Us_CurrBlkIdx = ((Us_CurrBlkIdx + NVMHAND_1U) % TI_FEE_NUMBER_OF_BLOCKS);
            Ucs_WriteReq = NVMHAND_1U;
    
        }
    
    
        return (uint32_t)Uc_Result;
    }
    /** @file ti_fee_cfg.c 
    *   @brief FEE Driver Implementation File
    *   @date 11-Dec-2018
    *   @version 04.07.01
    *
    *   This is the FEE configuration parameter file.
    */
    
    /* 
    * Copyright (C) 2009-2018 Texas Instruments Incorporated - www.ti.com  
    * 
    * 
    *  Redistribution and use in source and binary forms, with or without 
    *  modification, are permitted provided that the following conditions 
    *  are met:
    *
    *    Redistributions of source code must retain the above copyright 
    *    notice, this list of conditions and the following disclaimer.
    *
    *    Redistributions in binary form must reproduce the above copyright
    *    notice, this list of conditions and the following disclaimer in the 
    *    documentation and/or other materials provided with the   
    *    distribution.
    *
    *    Neither the name of Texas Instruments Incorporated nor the names of
    *    its contributors may be used to endorse or promote products derived
    *    from this software without specific prior written permission.
    *
    *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    *
    */
    
    
    /* USER CODE BEGIN (0) */
    /* USER CODE END */
    
    /* Include Files                                                              */
    
    #include "ti_fee.h"
    
    
    
    /*----------------------------------------------------------------------------*/
    /* Fee Version Check                                                          */
    
     #if (TI_FEE_MAJOR_VERSION != 3U)
         #error TI_FEE_Cfg.c: TI_FEE_SW_MAJOR_VERSION of TI_FEE.h is incompatible.
     #endif /* FEE_SW_MAJOR_VERSION */
     #if (TI_FEE_MINOR_VERSION != 0U)
         #error TI_FEE_Cfg.c: TI_FEE_SW_MINOR_VERSION of TI_FEE.h is incompatible.
     #endif /* FEE_SW_MINOR_VERSION */
     #if (TI_FEE_PATCH_VERSION != 2U)
         #error TI_FEE_Cfg.c: TI_FEE_SW_PATCH_VERSION of TI_FEE.h is incompatible.
     #endif /* FEE_SW_PATCH_VERSION */
    
    /*SAFETYMCUSW 580 S MR:1.1 <APPROVED> "Reason - This is the format to use for specifying memorysections."*/
     #define FEE_START_SEC_CONST_UNSPECIFIED
     /*SAFETYMCUSW 338 S MR:19.1 <APPROVED> "Reason - This is the format to use for specifying memorysections."*/
    #include "MemMap.h" 
    
    /*----------------------------------------------------------------------------*/
    /* TI Fee Configurations                                                     */
    
    /** @struct Fee_VirtualSectorConfigType 	*/
    /*  @brief Virtual Sector Configuration 	*/
    const Fee_VirtualSectorConfigType Fee_VirtualSectorConfiguration[TI_FEE_NUMBER_OF_VIRTUAL_SECTORS] =
    {
    
        /* Virtual Sector 1 */
        {
           /* Virtual sector number */      1U,
           /* Bank                  */      7U,      
           /* Start Sector          */      (Fapi_FlashSectorType)0U,
           /* End Sector            */      (Fapi_FlashSectorType)3U
        },
        /* Virtual Sector 2 */
        {
            /* Virtual sector number */     2U,
            /* Bank                  */     7U,
            /* Start Sector          */     (Fapi_FlashSectorType)4U,            
    		/* End Sector            */     (Fapi_FlashSectorType)7U
        }
        ,
        /* Virtual Sector 3 */
        {
            /* Virtual sector number */     3U,
            /* Bank                  */     7U,     
            /* Start Sector          */     (Fapi_FlashSectorType)8U,
            /* End Sector            */     (Fapi_FlashSectorType)11U     
        }
        ,
        /* Virtual Sector 4 */
        {
            /* Virtual sector number */     4U,
            /* Bank                  */     7U,
            /* Start Sector          */     (Fapi_FlashSectorType)12U,
            /* End Sector            */     (Fapi_FlashSectorType)15U        
        }
    };
    
    
    /* Block Configurations         */
    /* SourceId : HL_Fee_SourceId_2 */
    /* DesignId : HL_FEE_DesignId_3, HL_FEE_DesignId_8 */
    /* Requirements : HL_FEE_SR2, HL_FEE_SR3, HL_FEE_SR4, HL_FEE_SR6, HL_FEE_SR85, HL_FEE_SR86
                      HL_FEE_SR87, HL_FEE_SR88, HL_FEE_SR89, HL_FEE_SR90, HL_FEE_SR91 */
    const Fee_BlockConfigType Fee_BlockConfiguration[TI_FEE_NUMBER_OF_BLOCKS] =
    {
            /*      Block 1 */
            {
                   /* Block number                          */     1U, 
                   /* Block size                            */     64U,
                   /* Block immediate data used             */     TRUE,			   
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,			   
                   /* EEP number                            */     0U			   
            }
    
            ,
            /*      Block 2 */
            {
                   /* Block number                          */     2U, 
                   /* Block size                            */     64U,
                   /* Block immediate data used             */     TRUE,			   
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,		   
                   /* EEP number                            */     0U			   
            }
            ,
            /*      Block 3 */
            {
                   /* Block number                          */     3U, 
                   /* Block size                            */     64U,
                   /* Block immediate data used             */     TRUE,			   
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,			   
                   /* EEP number                            */     0U			   
            }
            ,
            /*      Block 4 */
            {
                   /* Block number                          */     4U, 
                   /* Block size                            */     64U,
                   /* Block immediate data used             */     TRUE,			   
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,			   
                   /* EEP number                            */     0U			   
            }
            ,
            /*      Block 5 */
            {
                   /* Block number                          */     5U, 
                   /* Block size                            */     64U,
                   /* Block immediate data used             */     TRUE,			   
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,			   
                   /* EEP number                            */     0U			   
            }
            ,
            /*      Block 6 */
            {
                   /* Block number                          */     6U, 
                   /* Block size                            */     64U,
                   /* Block immediate data used             */     TRUE,			   
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,			   
                   /* EEP number                            */     0U			   
            }
            ,
            /*      Block 7 */
            {
                   /* Block number                          */     7U, 
                   /* Block size                            */     64U,
                   /* Block immediate data used             */     TRUE,			   
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,			   
                   /* EEP number                            */     0U			   
            }
            ,
            /*      Block 8 */
            {
                   /* Block number                          */     8U, 
                   /* Block size                            */     64U,
                   /* Block immediate data used             */     TRUE,			   
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,			   
                   /* EEP number                            */     0U			   
            }
            ,
            /*      Block 9 */
            {
                   /* Block number                          */     9U, 
                   /* Block size                            */     64U,
                   /* Block immediate data used             */     TRUE,			   
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,			   
                   /* EEP number                            */     0U			   
            }
            ,
            /*      Block 10 */
            {
                   /* Block number                          */     10U, 
                   /* Block size                            */     64U,
                   /* Block immediate data used             */     TRUE,			   
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,		   
                   /* EEP number                            */     0U			   
            }
            ,
            /*      Block 11 */
            {
                   /* Block number                          */     11U, 
                   /* Block size                            */     64U,
                   /* Block immediate data used             */     TRUE,			   
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,			   
                   /* EEP number                            */     0U			   
            }
            ,
            /*      Block 12 */
            {
                   /* Block number                          */     12U, 
                   /* Block size                            */     64U,
                   /* Block immediate data used             */     TRUE,			   
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,			   
                   /* EEP number                            */     1U			   
            }
            ,
            /*      Block 13 */
            {
                   /* Block number                          */     13U, 
                   /* Block size                            */     64U,
                   /* Block immediate data used             */     TRUE,			   
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,			   
                   /* EEP number                            */     1U			   
            }
            ,
            /*      Block 14 */
            {
                   /* Block number                          */     14U, 
                   /* Block size                            */     64U,
                   /* Block immediate data used             */     TRUE,			   
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,		   
                   /* EEP number                            */     1U			   
            }
            ,
            /*      Block 15 */
            {
                   /* Block number                          */     15U, 
                   /* Block size                            */     64U,
                   /* Block immediate data used             */     TRUE,			   
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,			   
                   /* EEP number                            */     1U			   
            }
            ,
            /*      Block 16 */
            {
                   /* Block number                          */     16U, 
                   /* Block size                            */     64U,
                   /* Block immediate data used             */     TRUE,			   
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,			   
                   /* EEP number                            */     1U			   
            }
    		,
    		/* If project needs more than 16 blocks, add additional blocks here and also 
               modify TI_FEE_TOTAL_BLOCKS_DATASETS and TI_FEE_NUMBER_OF_BLOCKS in ti_fee_cfg.h 	*/
    /* USER CODE BEGIN (1) */
            /*      Block 17 */     /* Below code is written by Prajakta*/
            {
                   /* Block number                          */     17U,
                   /* Block size                            */     1024U,
                   /* Block immediate data used             */     TRUE,
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,
                   /* EEP number                            */     1U
            }
            ,
    
            /*      Block 18 */
            {
                   /* Block number                          */     18U,
                   /* Block size                            */     1024U,
                   /* Block immediate data used             */     TRUE,
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,
                   /* EEP number                            */     1U
            }
            ,
            /*      Block 19 */
            {
                   /* Block number                          */     19U,
                   /* Block size                            */     1024U,
                   /* Block immediate data used             */     TRUE,
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,
                   /* EEP number                            */     1U
            }
            ,
            /*      Block 20 */
            {
                   /* Block number                          */     20U,
                   /* Block size                            */     256U,
                   /* Block immediate data used             */     TRUE,
                   /* Number of write cycles                */     0x8U,
                   /* Device Index                          */     0x00000000U,
                   /* Number of DataSets                    */     1U,
                   /* EEP number                            */     1U
            }
            ,
    /* USER CODE END */
     
    };
    
    /*SAFETYMCUSW 580 S MR:1.1 <APPROVED> "Reason - This is the format to use for specifying memorysections."*/
    #define FEE_STOP_SEC_CONST_UNSPECIFIED
    /*SAFETYMCUSW 338 S MR:19.1 <APPROVED> "Reason - This is the format to use for specifying memorysections."*/
    #include "MemMap.h"
    
    /*----------------------------------------------------------------------------*/
    /* USER CODE BEGIN (2) */
    /* USER CODE END */
    

    Kindly go through it.

  • Programming 144bit (16 bytes data + 16 bits ECC) to flash will take 300us (maximum) and 40us (typical), so it won't take much to write a block of data to the flash. When the active virtual sector is full, the driver will erase another virtual sector and copy all the valid blocks to this erased sector. Erasing a flash sector will take up to 4 second (maximum) (0.03 typical). 

  • /**********************************************************************************************************************
     *  COPYRIGHT
     *  -------------------------------------------------------------------------------------------------------------------
     *  \verbatim
     *                 TEXAS INSTRUMENTS INCORPORATED PROPRIETARY INFORMATION
     *
     *                 Property of Texas Instruments, Unauthorized reproduction and/or distribution
     *                 is strictly prohibited.  This product  is  protected  under  copyright  law
     *                 and  trade  secret law as an  unpublished work.
     *                 (C) Copyright Texas Instruments - 2012.  All rights reserved.
     *
     *  \endverbatim
     *  -------------------------------------------------------------------------------------------------------------------
     *  FILE DESCRIPTION
     *  -------------------------------------------------------------------------------------------------------------------
     *         File:  fee.c
     *      Project:  Tms570_FEEDriver
     *       Module:  FEE Driver
     *    Generator:  None
     *
     *  Description:
     *********************************************************************************************************************/
    
     
     /**********************************************************************************************************************
     * INCLUDES
     *********************************************************************************************************************/
    #include "Fee.h"
    
    static StatusType Fee_InternalGetStatus(void);
    
    /**********************************************************************************************************************
     *  General Global Variables/defines
     *********************************************************************************************************************/
    /*SAFETYMCUSW 580 S MR:1.1 <APPROVED> "Reason - This is the format to use for specifying memorysections."*/
    #define FEE_START_SEC_CODE
    /*SAFETYMCUSW 338 S MR:19.1 <APPROVED> "Reason - This is the format to use for specifying memorysections."*/
    #include "MemMap.h"
    
    /***********************************************************************************************************************
     *  Fee_Init
     **********************************************************************************************************************/
    /*! \brief      This function is used to initialize the TI Fee module.
     *				It determines which Virtual Sector to use, sets up the Flash state machine.
     *  \param[in]  none
     *  \param[out] none
     *  \return     none
     *  \return     none
     *  \context    Function could be called from task level
     *  \note        FEE API.
     **********************************************************************************************************************/
     void Fee_Init(void)
     {
    	/* Call TI FEE Initialization API */
    	TI_Fee_Init();		
    	/* Update job result and module as required by MEMIF */
    	Fee_InternalUpdateGlobalStructure();				
     }
     
     /***********************************************************************************************************************
     *  Fee_Write
     **********************************************************************************************************************/
    /*! \brief      This function initiates the Write operation to a Block.
     *  \param[in]  uint16 BlockNumber
     *  \param[in]  uint8* DataBufferPtr
     *  \param[out] none
     *  \return     E_NOT_OK
     *  \return     E_OK
     *  \context    Function could be called from task level
     *  \note        FEE API.
     **********************************************************************************************************************/
     /*SAFETYMCUSW 62 D MR:16.7 <APPROVED> "Reason - since DataBufferPtr is modified by FEE, it cannot be declared de declared as const."*/
    Std_ReturnType Fee_Write(uint16 BlockNumber,uint8* DataBufferPtr)
    {
    	/*SAFETYMCUSW 331 S MR:10.1 <APPROVED> "Reason - Std_ReturnType is not part of FEE.This should be fixed outside of FEE."*/
    	Std_ReturnType oResult=E_OK;
    	
    	/* Call TI FEE Write API */
    	oResult = TI_Fee_WriteSync(BlockNumber,DataBufferPtr);
    	
    	/* Update job result and module state as required by MEMIF */
    	Fee_InternalUpdateGlobalStructure();
    	
    	return(oResult);
    }
    
    /***********************************************************************************************************************
     *  Fee_MainFunction
     **********************************************************************************************************************/
    /*! \brief      This function is a cyclic function. It will Write data, Read Data, Invalidate Block, Erase Block,
     *				Copy blocks, Erase Sectors.
     *  \param[in]  none
     *  \param[in]  none
     *  \param[out] none
     *  \return     none 
     *  \context    Function could be called from task level
     *  \note        FEE API.
     **********************************************************************************************************************/
     void Fee_MainFunction(void)
    {
    	/* Call TI FEE Main API */
    	TI_Fee_MainFunction();	
    	
    	/* Update job result and module as required by MEMIF */
    	Fee_InternalUpdateGlobalStructure();	
    }
    
    /***********************************************************************************************************************
     *  Fee_Read
     **********************************************************************************************************************/
    /*! \brief      This function performs the Read operation on the Block.
     *  \param[in]  uint16 BlockNumber
     *  \param[in]  uint16 BlockOffset
     *  \param[in]  uint8* DataBufferPtr
     *  \param[in]  uint16 Length
     *  \param[out] none
     *  \return     none 
     *  \context    Function could be called from task level
     *  \note        FEE API.
     **********************************************************************************************************************/
     /*SAFETYMCUSW 62 D MR:16.7 <APPROVED> "Reason - since DataBufferPtr is modified by FEE, it cannot be declared de declared as const."*/
    Std_ReturnType Fee_Read(uint16 BlockNumber,uint16 BlockOffset,uint8* DataBufferPtr,uint16 Length)
    {
    	/*SAFETYMCUSW 331 S MR:10.1 <APPROVED> "Reason - Std_ReturnType is not part of FEE.This should be fixed outside of FEE."*/
    	Std_ReturnType oResult=E_OK;
    	
    	/* Call TI FEE Read API */
    	oResult = TI_Fee_Read(BlockNumber,BlockOffset,DataBufferPtr,Length);	
    	
    	/* Update job result and module state as required by MEMIF */
    	Fee_InternalUpdateGlobalStructure();
    			
    	return(oResult);	
    }
    
    /***********************************************************************************************************************
     *  Fee_EraseImmediateBlock
     **********************************************************************************************************************/
    /*! \brief     	This function performs the Erase Immediate operation on a block .
     *  \param[in]	uint16 BlockNumber
     *  \param[out] none 
     *  \return 	Std_ReturnType
     *  \context    
     *  \note        FEE API.
     **********************************************************************************************************************/
     Std_ReturnType Fee_EraseImmediateBlock(uint16 BlockNumber)
    {
    	/*SAFETYMCUSW 331 S MR:10.1 <APPROVED> "Reason - Std_ReturnType is not part of FEE.This should be fixed outside of FEE."*/
    	Std_ReturnType oResult=E_OK;
    	
    	/* Call TI FEE Erase Immediate API */
    	oResult = TI_Fee_EraseImmediateBlock(BlockNumber);	
    	
    	/* Update job result and module state as required by MEMIF */
    	Fee_InternalUpdateGlobalStructure();
    			
    	return(oResult);
    }
    
    /***********************************************************************************************************************
     *  Fee_InvalidateBlock
     **********************************************************************************************************************/
    /*! \brief     	This function performs the Invalidate operation on a block .
     *  \param[in]	uint16 BlockNumber
     *  \param[out] none 
     *  \return 	Std_ReturnType
     *  \context    
     *  \note        FEE API.
     **********************************************************************************************************************/
     Std_ReturnType Fee_InvalidateBlock(uint16 BlockNumber)
    {
    	/*SAFETYMCUSW 331 S MR:10.1 <APPROVED> "Reason - Std_ReturnType is not part of FEE.This should be fixed outside of FEE."*/
    	Std_ReturnType oResult=E_OK;
    
    	/* Call TI FEE Invalidate Block API */
    	oResult = TI_Fee_InvalidateBlock(BlockNumber);	
    	
    	/* Update job result and module state as required by MEMIF */
    	Fee_InternalUpdateGlobalStructure();
    			
    	return(oResult);
    }
    
    /***********************************************************************************************************************
     *  Fee_Cancel
     **********************************************************************************************************************/
    /*! \brief     	This functions cancels an ongoing operation.
     *  \param[in]	uint16 BlockNumber
     *  \param[out] none 
     *  \return 	Std_ReturnType
     *  \context    
     *  \note        FEE API.
     **********************************************************************************************************************/
     void Fee_Cancel(void)
    {
    	uint8 u8EEPIndex = 0U;
    	
    	/* Call TI FEE Cancel API */
    	TI_Fee_Cancel(u8EEPIndex);
    	#if(TI_FEE_NUMBER_OF_EEPS == 2U)
    	TI_Fee_Cancel(u8EEPIndex+1U);
    	#endif	
    	
    	/* Update job result and module state as required by MEMIF */
    	Fee_InternalUpdateGlobalStructure();
    }
    
    /***********************************************************************************************************************
     *  Fee_GetStatus
     **********************************************************************************************************************/
    /*! \brief      This function is pre-compile time configurable by the parameter FlsGetStatusApi
     *  \param[in]	none
     *  \param[out] none 
     *  \return 	StatusType
     *  \context    
     *  \note        FEE API.
     **********************************************************************************************************************/
    /* This function returns the Status of the FEE module */
    StatusType Fee_GetStatus(void)
    {
    	#if(TI_FEE_NUMBER_OF_EEPS == 1U)
    	uint8 u8EEPIndex = 0U;
    	#endif
    	StatusType ModuleState = UNINIT;
    	
    	/* Update job result and module state as required by MEMIF */
    	Fee_InternalUpdateGlobalStructure();
    	
    	#if(TI_FEE_NUMBER_OF_EEPS == 2U)
    	ModuleState = Fee_InternalGetStatus();		
    	#elif(FEE_NUMBER_OF_EEPS == 1U)	
    	if((TI_Fee_oStatusWord[u8EEPIndex].Fee_StatusWordType_ST.Erase != 0U)||
    	   (TI_Fee_oStatusWord[0].Fee_StatusWordType_ST.Copy != 0U)		
    	  )
    	{
    		ModuleState = (StatusType)BUSY;
    	}
    	else
    	{
    		ModuleState = (StatusType)TI_Fee_GlobalVariables[u8EEPIndex].Fee_ModuleState;
    	}
    	#endif	
    	return(ModuleState);
    }
    
    /***********************************************************************************************************************
     *  Fee_GetJobResult
     **********************************************************************************************************************/
    /*! \brief      This function returns the Job result.
     *  \param[in]  u8EEPIndex
     *  \param[out] none
     *  \return     Job Result
     *  \context    Function could be called from task level
     *  \note       TI FEE API.
     **********************************************************************************************************************/
    TI_FeeJobResultType Fee_GetJobResult(void)
    {	
    	/* Update job result and module as required by MEMIF */
    	Fee_InternalUpdateGlobalStructure();	
    	
    	return((TI_FeeJobResultType)TI_Fee_GlobalVariables[TI_Fee_u8DeviceIndex].Fee_u16JobResult);
    }
    
    /***********************************************************************************************************************
     *  Fee_InternalUpdateGlobalStructure
     **********************************************************************************************************************/
    /*! \brief      This function updates the module state and job result.
     *  \param[in]	none
     *  \param[out] none 
     *  \return 	none
     *  \context    
     *  \note       FEE Internal API.
     **********************************************************************************************************************/ 
    static
    void Fee_InternalUpdateGlobalStructure(void)
    {	
    	uint8 u8EEPIndex = 0U;	
     
    	while(u8EEPIndex<TI_FEE_NUMBER_OF_EEPS)
    	{	
    		/* Update correct info for MEMIF */
    		switch (TI_Fee_GlobalVariables[u8EEPIndex].Fee_u16JobResult)
    		{
    			case JOB_OK :
    				TI_Fee_GlobalVariables[u8EEPIndex].Fee_u16JobResult = (TI_FeeJobResultType)JOB_OK;
    				break;
    			case JOB_FAILED:	
    				TI_Fee_GlobalVariables[u8EEPIndex].Fee_u16JobResult = (TI_FeeJobResultType)JOB_FAILED;
    				break;
    			case JOB_PENDING:
    				TI_Fee_GlobalVariables[u8EEPIndex].Fee_u16JobResult = (TI_FeeJobResultType)JOB_PENDING;
    				break;
    			case JOB_CANCELLED:
    				TI_Fee_GlobalVariables[u8EEPIndex].Fee_u16JobResult = (TI_FeeJobResultType)JOB_CANCELLED;
    				break;
    			case BLOCK_INCONSISTENT:
    				TI_Fee_GlobalVariables[u8EEPIndex].Fee_u16JobResult = (TI_FeeJobResultType)BLOCK_INCONSISTENT;
    				break;
    			case BLOCK_INVALID:
    				TI_Fee_GlobalVariables[u8EEPIndex].Fee_u16JobResult = (TI_FeeJobResultType)BLOCK_INVALID;
    				break;
    			default:
    				break;
    		}
    		switch (TI_Fee_GlobalVariables[u8EEPIndex].Fee_ModuleState)
    		{
    			case IDLE:
    				TI_Fee_GlobalVariables[u8EEPIndex].Fee_ModuleState = (TI_FeeModuleStatusType)IDLE;
    				break;
    			case BUSY:
    				TI_Fee_GlobalVariables[u8EEPIndex].Fee_ModuleState = (TI_FeeModuleStatusType)BUSY;
    				break;
    			case BUSY_INTERNAL:
    				TI_Fee_GlobalVariables[u8EEPIndex].Fee_ModuleState = (TI_FeeModuleStatusType)BUSY_INTERNAL;
    				break;
    			default :
    				TI_Fee_GlobalVariables[u8EEPIndex].Fee_ModuleState = (TI_FeeModuleStatusType)UNINIT;
    				break;
    		}
    		if((TI_Fee_oStatusWord[u8EEPIndex].Fee_StatusWordType_ST.Erase != 0U))
    		{
    			TI_Fee_GlobalVariables[u8EEPIndex].Fee_u16JobResult = (TI_FeeJobResultType)JOB_PENDING;
    		}
    		u8EEPIndex++;
    	}
    }
    
    
    #if(TI_FEE_NUMBER_OF_EEPS == 2U)
    static StatusType Fee_InternalGetStatus(void)
    {
    	StatusType ModuleState = UNINIT;
    	
    	if((TI_Fee_GlobalVariables[0].Fee_ModuleState == UNINIT)
    	   &&(TI_Fee_GlobalVariables[1].Fee_ModuleState == UNINIT))
    	{
    		ModuleState = (StatusType)UNINIT;
    	}
    	else if((TI_Fee_GlobalVariables[0].Fee_ModuleState == UNINIT)
    			&&(TI_Fee_GlobalVariables[1].Fee_ModuleState == IDLE))
    	{
    		ModuleState = (StatusType)IDLE;
    	}
    	else if((TI_Fee_GlobalVariables[0].Fee_ModuleState == UNINIT)
    			&&(TI_Fee_GlobalVariables[1].Fee_ModuleState == BUSY))
    	{
    		ModuleState = (StatusType)BUSY;
    	}	
    	else if((TI_Fee_GlobalVariables[0].Fee_ModuleState == UNINIT)
    			&&(TI_Fee_GlobalVariables[1].Fee_ModuleState == BUSY_INTERNAL))
    	{
    		ModuleState =(StatusType) BUSY_INTERNAL;
    	}
    	else
    	{
    		/* MISRA C Compliance */
    	}
    	
    	
    	if((TI_Fee_GlobalVariables[0].Fee_ModuleState == IDLE)
    	   &&(TI_Fee_GlobalVariables[1].Fee_ModuleState == UNINIT))
    	{
    		ModuleState = (StatusType)IDLE;
    	}
    	else if((TI_Fee_GlobalVariables[0].Fee_ModuleState == IDLE)
    		    &&(TI_Fee_GlobalVariables[1].Fee_ModuleState == IDLE))
    	{
    		ModuleState =(StatusType) IDLE;
    	}
    	else if((TI_Fee_GlobalVariables[0].Fee_ModuleState == IDLE)
    			&&(TI_Fee_GlobalVariables[1].Fee_ModuleState == BUSY))
    	{
    		ModuleState = (StatusType)BUSY;
    	}	
    	else if((TI_Fee_GlobalVariables[0].Fee_ModuleState == IDLE)
    			&&(TI_Fee_GlobalVariables[1].Fee_ModuleState == BUSY_INTERNAL))
    	{
    		ModuleState = (StatusType)BUSY_INTERNAL;
    	}
    	else
    	{
    		/* MISRA C Compliance */
    	}
    		
    	if((TI_Fee_GlobalVariables[0].Fee_ModuleState == BUSY)
    		&&(TI_Fee_GlobalVariables[1].Fee_ModuleState == UNINIT))
    	{
    		ModuleState = (StatusType)BUSY;
    	}
    	else if((TI_Fee_GlobalVariables[0].Fee_ModuleState == BUSY)
    			&&(TI_Fee_GlobalVariables[1].Fee_ModuleState == IDLE))
    	{
    		ModuleState = (StatusType)BUSY;
    	}
    	else if((TI_Fee_GlobalVariables[0].Fee_ModuleState == BUSY)
    			&&(TI_Fee_GlobalVariables[1].Fee_ModuleState == BUSY))
    	{
    		ModuleState = (StatusType)BUSY;
    	}	
    	else if((TI_Fee_GlobalVariables[0].Fee_ModuleState == BUSY)
    			&&(TI_Fee_GlobalVariables[1].Fee_ModuleState == BUSY_INTERNAL))
    	{
    		ModuleState = (StatusType)BUSY;
    	}
    	else
    	{
    		/* MISRA C Compliance */
    	}
    		
    	
    	if((TI_Fee_GlobalVariables[0].Fee_ModuleState == BUSY_INTERNAL)
    		&&(TI_Fee_GlobalVariables[1].Fee_ModuleState == UNINIT))
    	{
    		ModuleState = (StatusType)BUSY_INTERNAL;
    	}
    	else if((TI_Fee_GlobalVariables[0].Fee_ModuleState == BUSY_INTERNAL)
    			&&(TI_Fee_GlobalVariables[1].Fee_ModuleState == IDLE))
    	{
    		ModuleState = (StatusType)BUSY_INTERNAL;
    	}
    	else if((TI_Fee_GlobalVariables[0].Fee_ModuleState == BUSY_INTERNAL)
    			&&(TI_Fee_GlobalVariables[1].Fee_ModuleState == BUSY))
    	{
    		ModuleState = (StatusType)BUSY;
    	}	
    	else if((TI_Fee_GlobalVariables[0].Fee_ModuleState == BUSY_INTERNAL)
    			&&(TI_Fee_GlobalVariables[1].Fee_ModuleState == BUSY_INTERNAL))
    	{
    		ModuleState = (StatusType)BUSY_INTERNAL;
    	}
    	else
    	{
    		/* MISRA C Compliance */
    	}
    	
    	
    	if((TI_Fee_oStatusWord[0].Fee_StatusWordType_ST.Erase != 0U) ||
    	   (TI_Fee_oStatusWord[1].Fee_StatusWordType_ST.Erase != 0U) ||
    	   (TI_Fee_oStatusWord[0].Fee_StatusWordType_ST.Copy != 0U) ||
    	   (TI_Fee_oStatusWord[1].Fee_StatusWordType_ST.Copy != 0U)
    	  )
    	{
    		ModuleState = (StatusType)BUSY;
    	}	
    	return(ModuleState);
    }
    #endif
    
    /*SAFETYMCUSW 580 S MR:1.1 <APPROVED> "Reason - This is the format to use for specifying memorysections."*/
    #define FEE_STOP_SEC_CODE
    /*SAFETYMCUSW 338 S MR:19.1 <APPROVED> "Reason - This is the format to use for specifying memorysections."*/
    #include "MemMap.h"
    
    /**********************************************************************************************************************
     *  END OF FILE: fee.c
     *********************************************************************************************************************/
     
    
    
    fee.h
    /*
     * main.c
     */
    #include "F021.h"
    #include "fee.h"
    
    uint16 u16JobResult,Status;
    Std_ReturnType oResult=E_OK;
    
    uint8 SpecialRamBlock[64]; //block size is 64 bytes defined in HALCOGen
    
    int main(void) {
    	
    	unsigned int BlockNumber, BlockOffset;
    
    	volatile unsigned int loop;
    
    
    	for(loop=0;loop<64;loop++)
    	    SpecialRamBlock[loop] = loop;
    
    	Fee_Init();
    	do
    	{
    		Fee_MainFunction();
    		Status=Fee_GetStatus();
    	}
    	while(Status!= IDLE);
    
    	for(loop=0;loop<64;loop++)
    	{
    		do
    		{
    			Fee_MainFunction();
    			Status=Fee_GetStatus();
    		}
    		while(Status!= IDLE);
    	}
    
    	Fee_Write(1, &SpecialRamBlock[0]);  //write block #1 to EEP #0
    	do
    	{
    		Fee_MainFunction();
    		Status=Fee_GetStatus();
    	}
    	while(Status!= IDLE);
    
    	Fee_Write(2, &SpecialRamBlock[0]);    //write block #2 to EEP #0
    	do
    	{
    		Fee_MainFunction();
    		Status=Fee_GetStatus();
    	}
    	while(Status!= IDLE);
    
    	Fee_Write(3, &SpecialRamBlock[0]);    //write block #3 to EEP #0
    	do
    	{
    		Fee_MainFunction();
    		Status=Fee_GetStatus();
    	}
    	while(Status!= IDLE);
    
    	Fee_Write(4, &SpecialRamBlock[0]);    //write block #4 to EEP #0
    	do
    	{
    		Fee_MainFunction();
    		Status=Fee_GetStatus();
    	}
    	while(Status!= IDLE);
    
    	Fee_Write(13, &SpecialRamBlock[0]);     //write block #13 to EEP #1
    	do
    	{
    		Fee_MainFunction();
    		Status=Fee_GetStatus();
    	}
    	while(Status!= IDLE);
    
    	Fee_Write(14, &SpecialRamBlock[0]);     //write block #14 to EEP #1
    	do
    	{
    		Fee_MainFunction();
    		Status=Fee_GetStatus();
    	}
    	while(Status!= IDLE);
    
    	Fee_Write(15, &SpecialRamBlock[0]);     //write block #15 to EEP #1
    	do
    	{
    		Fee_MainFunction();
    		Status=Fee_GetStatus();
    	}
    	while(Status!= IDLE);
    
    	Fee_Write(16, &SpecialRamBlock[0]);     //write block #16 to EEP #1
    	do
    	{
    		Fee_MainFunction();
    		Status=Fee_GetStatus();
    	}
    	while(Status!= IDLE);
    
    
    	BlockNumber=0x3;
    	for(loop=0;loop<20;loop++)
    	{
    		SpecialRamBlock[0] = loop+1;
    		Fee_Write(BlockNumber, &SpecialRamBlock[0]);        //write block #3 to EEP #0
    		do
    		{
    			Fee_MainFunction();
    			Status=Fee_GetStatus();
    		}
    		while(Status!= IDLE);
    	}
    
    	BlockNumber=0x12;
    	for(loop=0;loop<20;loop++)
    	{
    		SpecialRamBlock[0] = loop+1;
    		Fee_Write(BlockNumber, &SpecialRamBlock[0]);        //write block #16 to EEP #1
    		do
    		{
    			Fee_MainFunction();
    			Status=Fee_GetStatus();
    		}
    		while(Status!= IDLE);
    	}
    
    	return 0;
    }
    

    Can you try the functions defined in fee.c to program data to EEPS (EEPS>1)?

  • 1. Did you have gone through my file. Is there any issue ?

    2. What is benefit of the fee.c and main.c given by you ?

  • Hi Prajakta,

    To Fee_GetStatus and Fee_job_result, please use the EEPS number as the function argument:

    TI_Fee_GetStatus( uint8 u8EEPIndex)

    TI_Fee_GetJobResult(uint8 u8EEPIndex)

    Nothing special in fee.c in my last message, I used this file to run test years ago for EEPS=2. The HalCoGen generated driver can support both EEPS=1 and EEPS=2.

  • TI_Fee_GetStatus(NVMHAND_0U);

    TI_Fee_GetJobResult(NVMHAND_0U);

    In both cases, NVMHAND_0U has value 0. i.e. EEP0 .

  • I didn't test your code. If you program a data block in EEP1, the EEP1 should be used in TI_Fee_GetStatus(...) and TI_Fee_GetJobResult(...).

    BTW, you don't have to call TI_Fee_MainFunction() function for sync write and sync read.

    Have you tried my exmaple?