Other Parts Discussed in Thread: HALCOGEN
Hello,
I am requriing some help for the following: my need is to write some configuration parameters in a non volatile memory (parameters should not be lost after a power off of the µC). It's not a big amount of data, something like 25 or maybe 30 doubles, which is about 240 bytes.
I was thinking of using the flash EEPROM to do this, as it is made for this from what I understood.
So I tried the exemple shown in HalCogen, but it does not work: the code stay stuck in the first loop, because the Status is always UNINIT.
Here is the exemple code below:
void write_to_flash(void)
{
uint16 u16JobResult,Status;
Std_ReturnType oResult=E_OK;
unsigned char read_data[100]={0};
uint8 SpecialRamBlock[100];
unsigned char pattern;
uint16 u16writecounter;
unsigned int FeeVirtualSectorNumber;
unsigned char VsState, u8EEPIndex;
unsigned char u8VirtualSector;
uint8 Test_Recovery;
uint8 Test_Cancel;
unsigned int BlockNumber;
unsigned int BlockOffset, Length;
unsigned char *Read_Ptr=read_data;
unsigned int loop;
/* Initialize RAM array.*/
for(loop=0;loop<100;loop++)SpecialRamBlock[loop] = loop;
/* Initialize FEE. This will create Virtual sectors, initialize global variables etc.*/
TI_Fee_Init();
do
{
TI_Fee_MainFunction();
delay();
Status=TI_Fee_GetStatus(0 );
}
while(Status!= IDLE);
/* Write the block into EEP Asynchronously. Block size is configured in ti_fee_cfg.c file. Default Block size is
8 bytes */
BlockNumber=0x1;
TI_Fee_WriteAsync(BlockNumber, &SpecialRamBlock[0]);
do
{
TI_Fee_MainFunction();
delay();
Status=TI_Fee_GetStatus(0);
}
while(Status!=IDLE);
/* Write the block into EEP Synchronously. Write will not happen since data is same. */
TI_Fee_WriteSync(BlockNumber, &SpecialRamBlock[0]);
/* Read the block with unknown length */
BlockOffset = 0;
Length = 0xFFFF;
oResult=TI_Fee_Read(BlockNumber,BlockOffset,Read_Ptr,Length);
do
{
TI_Fee_MainFunction();
delay();
Status=TI_Fee_GetStatus(0);
}
while(Status!=IDLE);
/* Invalidate a written block */
TI_Fee_InvalidateBlock(BlockNumber);
do
{
TI_Fee_MainFunction();
delay();
Status=TI_Fee_GetStatus(0);
}
while(Status!=IDLE);
/* Format bank 7 */
TI_Fee_Format(0xA5A5A5A5U);
}
I have installed the flash API correctly I guess, and link the code with "C:\ti\Hercules\F021 Flash API\02.01.01\F021_API_CortexR4_BE_L2FMC_V3D16.lib"
I have done nothing in HalCogen, except enable FEE drivers. And I am using FreeRTOS.
Any clue would be helpful.
I really read a lot of topic, but found no answer on how to make this work. The documentation is not very clear about it, and even if my need is really basic, I could not figure it out.
Thanks
Audry