Other Parts Discussed in Thread: HALCOGEN
Hello all,
As a graduate engineer who is newbie in embedded world, the embedded project i am working on requires me to write a variable to the flash and use it when power cut off and comes back again. I am trying to get the fee example in HALCoGeN to work but no luck till now. I am watching the expressions from example code like "SpecialRamBlock[0]" and "oResult" if "BlockNumber" 1 is written to them or can be read from them but i don't see anything changes in debug. I left my HALCoGeN configuration default as instructed in example and i am using the example code just the way it is.
Example code:
#include "ti_fee.h"
/* USER CODE END */
/* Include Files */
#include "sys_common.h"
/* USER CODE BEGIN (1) */
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;
void delay(void)
{
unsigned int dummycnt=0x0000FFU;
do
{
dummycnt--;
}
while(dummycnt>0);
}
/* USER CODE END */
/* USER CODE BEGIN (2) */
/* USER CODE END */
void main(void)
{
/* USER CODE BEGIN (3) */
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);
while(1);
Default HALCoGeN configuration..
I believe i have linked F021 flash API and included the F021 headers..
Can you help me out in this seemingly simple matter ? What do i miss out ? Thanks in advance..