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.

RTOS/TMS570LS0714: 570 FEE Operation too long time with the F021 LIb.

Part Number: TMS570LS0714

Tool/software: TI-RTOS

Hi all,

I use TMS570 0714 CPU for motor control and the interrupt of 100us(or less, generated by PWM) must used . 

And we ued another interrupt 1ms with HET generated.  The PWM  interrupt priority is high than the HET's (MUST),

So the PWM interupt is FIQ and the HET interrupt is IRQ mode.

At first  we  put the follow codes into  HET interrupt . 

if(TI_Fee_GetStatus(0) == IDLE)
{
EEPROM_Process(&g_eeprom);
}
TI_Fee_MainFunction();

EEPROM_Process function below:

/**
* The application layer Eeeprom main process function .
* This function will process write、read、recover、record.
* @param[in] e is the structure of the EEPROM Object.
*/
void EEPROM_Process(PEEPROM e)
{
uint8 m;
uint8* ReadBlockStartAddress = 0;
uint16* BlockStartAddress = 0;
Std_ReturnType OperationResult = E_OK;
// EEPROMBUF buf;

if(e->Command.bit.recover != 0)
{
e->Status.bit.WriteBusy = 0;
e->Status.bit.ReadBusy = 0;
e->Command.bit.read = 0;
e->Status.bit.error = 0;
e->Status.bit.ForceRecover = 1;
switch(e->Command.bit.recover) //choose type
{
case 1:
break;
case 2://block3
RecoverFlashData(e,&MotorParaRecover[0],&e->Para.Blocks.MotorPara[0],Block3_LENGTH);
e->WriteFlag.all[0] |= 0x00000004;
e->Command.bit.write = 1;
break;
case 3://block4
RecoverFlashData(e,&UserParaRecover[0],&e->Para.Blocks.UserPara[0],Block4_LENGTH);
e->WriteFlag.all[0] |= 0x00000008;
e->Command.bit.write = 1;
break;
case 4://All
RecoverFlashData_AllBlock(e);
e->WriteFlag.all[0] |= 0x0000000C;
e->Command.bit.write = 1;
break;

default:
break;
}
e->Command.bit.recover = 0;

}

if((e->ErrorFlag.all == 0) && (e->Status.bit.OperateByte == 0))
{
if(e->Status.bit.WriteBusy == 1) //last operation is to write
{
m = (e->CurrentBlock-1)/32;
e->WriteFlag.all[m] = (e->WriteFlag.all[m] >> (e->CurrentBlock-m*32)) << (e->CurrentBlock-m*32);
if(e->WriteFlag.all == 0)
{
e->Command.bit.write = 0;
}

e->Status.bit.WriteBusy = 0;
}

else if(e->Status.bit.ReadBusy == 1) //last operation is to read
{
m = (e->CurrentBlock-1)/32;
e->ReadFlag.all[m] = (e->ReadFlag.all[m] >> (e->CurrentBlock-m*32)) << (e->CurrentBlock-m*32);
if(e->ReadFlag.all == 0)
{
e->Command.bit.read = 0;
}
e->Status.bit.ReadBusy = 0;
}
if(e->Status.bit.ReadBusy == 0 && e->Status.bit.WriteBusy == 0 && e->Status.bit.RecordBusy == 0) //eeprom is idle
{
if(e->Command.bit.write == 1)
{
if((!e->Status.bit.UnderVoltage) || e->Status.bit.ForceRecover)
{
e->CurrentBlock = EEPROM_BlockSelectWrite(e); //calculate BlockNumber
if(e->CurrentBlock > EEPROM_PARA_BLOCK || e->CurrentBlock < 1)
{
e->Command.bit.write = 0;
return;
}
BlockStartAddress = EEPROM_SearchBlockStartAddress(e,e->CurrentBlock);
EEPROM_WriteBuf(BlockStartAddress, &e->TxBuf[0],e->NeedWriteNum); //write_para -> BUF
e->Status.bit.WriteBusy = 1;
e->Status.bit.OperateByte = 1;
OperationResult = TI_Fee_WriteAsync(e->CurrentBlock,&e->TxBuf[0]);
if(OperationResult == E_NOT_OK)
{
//e->Command.bit.write = 0;
return;
}
e->Status.bit.OperateByte = 0;
TI_FEE_Main_Process();
}
}
else if(e->Command.bit.read == 1)
{
e->CurrentBlock = EEPROM_BlockSelectRead(e);
if( e->CurrentBlock > EEPROM_PARA_BLOCK ||e->CurrentBlock < 1)
{
e->Command.bit.read = 0;
return;
}

ReadBlockStartAddress = EEPROM_SearchBlockStartAddress2(e,e->CurrentBlock);
e->Status.bit.ReadBusy = 1;
e->Status.bit.OperateByte = 2;
OperationResult = TI_Fee_Read(e->CurrentBlock,e->ReadOffset,ReadBlockStartAddress,e->ReadLength);
if(OperationResult == E_NOT_OK)
{
//e->Command.bit.read = 0;
return;
}
e->Status.bit.OperateByte = 0;
TI_FEE_Main_Process();
}
}
}
}

After RUN, the HET interrupt stop and the PWM interrupt STOP.

And I move the code into pwm interrupt (FIQ) ,after several minutes, the pwm interupt run ,but het interrupt stop.

The reason we use oscilloscope find FEE read or write time too long ,maybe 30us or more ,and is there any  design it can't be interupt  or other reason?

or when you operate flash (or fee),it can not be interrupt ,and stop the other interrupt?

Actrally we want put those code into het interrupt and made the pwm interrupt as less codes as possible to inprove the cpu occupancy.

can you guys help me ?  too thanks for you.

  • Hello Arvin,

    I have forwarded your questions to our FEE expert. He will check it for you. Thanks for your patience.
  • Hello Arvin,

    Can you try to use TI_Fee_ReadSync(..) and TI_Fee_WriteSync(..) and measure the time used by the ISR? It might take longer than your expectation.

  • Hi Arvin,

    Are you using any RTOS in your application?

    I strongly recommend not to use Flash Operation ( FEE Write especially ) inside ISR. 

    FEE write can initiate an Flash Erase operation during the Page Swap (i.e., if Virtual Sector is full and moves to different Virtual Sector and perform erase of old Virtual sector). which could take considerable amount of time and also it varied from device to device and with ageing too. 

    You can initiate a Async Write inside ISR and perform TI_Fee_Mainfunction outside of ISR.

    Since I do not know your Application SW Architecture, I cannot guess the frequency in which write operations are  triggered. 

    If Application uses RTOS, I would recommend all FEE users to run a thread once in few msec periodically and call  TI_Fee_Mainfunction...

    In case of non RTOS i recommend to use RTI / some timer to create a tick and in the ISR just call TI_Fee_Mainfunction. 

    TI_Fee_Mainfunction is the async routine in which Read or write operation is performed when Async write/read is used. 

    I do not recommend to use FEE SYNC Read/write API's inside ISR.   

  • Hi,QJ:

    TI_Fee_WriteSync() take 50us more or less and TI_Fee_ReadSync(..) takes a litter time.

    The question is we can't use it (especily  in 100us(or 65us) interrupt ) .It takes too much occupancy for us and result for others' interrupt or os threads stopping.

     

    BR,

    Arvin Lu

  • Hi Prathap,
    We use RTOS in our SW.
    My application SW architecture is 3 threads(RTOS) and 2 interrupts. The interuput is 100us(pwm generate) and 1ms(het generate).
    Since TI_Fee_WriteSync() takes 50us (too much for us), can I put both TI_Fee_WriteSync() andTI_Fee_ReadSync () into threads.
    After put those two into threads directly , sw reset repeatly.
    Afer put TI_Fee_WriteSync() into 1ms interrupt (IRQ) and perform TI_Fee_Mainfunction outside of ISR(one of threads), RTOS Stop.

    B.R,
    Arvin Lu
  • Hi Arvin,

    You can use TI_Fee_WriteAsync function in your task, this will not take much cpu cycles since it will initiate the write and return, the actual write is performed in TI_Fee_MainFunction.

    You must have a periodic task in which you perform the TI_Fee_MainFunction.

    Application can check for the FEE Status before the next read and write operation just to make sure the TI_Fee_MainFunction completed the Read/write operations.

    This way Application is not halted even during the lengthier Erase Operations, which typically happens during Page Swap.  

  • Hi Prathap,
    I use TI_Fee_MainFunction and TI_Fee_WriteAsync in my task, When operating the flash API( Fapi_doBlankCheck),Application generate an ISR and lead to operating the flash API be interrupted,The last my Application can not run.
    So at the time of flash API operation is not interrupted by an ISR.
  • hi:

    My platform is TMS5700714+HAL4.7.0+FreeRTOS9.0。

    TI_Fee_Mainfunction and Read or write operation is Async, in 4 ms task。I have a few questions about FEE.

    1、FEE operation can be interrupt by ISR,because my program have a 100us ISR。Let me put it another way,Flash operation isnot can be interrupt???

    2、API of FEE  has to be executed in privileged mode??? because task of RTOS be executed in user mode.

  • user1993508 said:

    1、FEE operation can be interrupt by ISR,because my program have a 100us ISR。Let me put it another way,Flash operation isnot can be interrupt???

    Yes, FEE operation can be interrupted by ISR because it does not need any critical sessions to be protected by disabling Interrupt.
    Flash Operations happen in Parallel, FEE drive will setup the Flash Wrapper and it will take care of the Flash Operation like Erase, Programming in the background.  

    user1993508 said:

    2、API of FEE  has to be executed in privileged mode??? because task of RTOS be executed in user mode.

    Yes, FEE API routines calls F021 Flash API which must be run in a privileged mode (a mode other than user) to allow access to the Flash memory controller registers

  • thank you very much!

    in other words,TI_Fee_MainFunction has to be executed in privileged mode? but in FreeRTOS, task run in user mode,

    so i need to switch to privileged mode in task. I found no specific practice on the datasheet.

    what shoud i do that switch to privileged mode or set access to the Flash memory controller registers in user mode and privileged mode.

    thank you!