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.