Hello,guys. now I get a problem.
First, I configure eTPU channel 24/25/26/27 as input capture,the code is as follows:
errorCode = fs_etpu_ic_init(24, FS_ETPU_PRIORITY_HIGH, ETPU_IC_MODE_CONT, FS_ETPU_TCR1, ETPU_IC_ANY_EDGE, 1);
then, I used these channels to calculate the pulse width (T),the principal is as shown below,
and the code is as follows:
if( edge == CONF_EDGE_RISING )
numTcntEnd = 0x00FFFFFFUL & (uint32)fs_etpu_ic_read_final_time(24);
if(numTcntStart <= numTcntEnd)
PW = numTcntEnd - numTcntStart;
PW = 0x00FFFFFFUL - numTcntStart + numTcntEnd;
numTcntStart = 0x00FFFFFFUL & (uint32)fs_etpu_ic_read_final_time(24);
Later, when MCU was running, PW is calculated correctly.
But when I configure eTPU channel 0/1/2/3 as QOM output, and were performed in interrupt2(see picture1),then PW is calculated mistakenly sometimes. The code of set qom output is as follows:
errorCode=fs_etpu_qom_init(0,FS_ETPU_PRIORITY_HIGH ,FS_ETPU_QOM_SINGLE_SHOT,FS_ETPU_TCR1,CONF_IGN_IDLE,FS_ETPU_QOM_IMMEDIATE ,0,1,2,event.Ign[x]);
It's very strange, and I get no idea to solve it, can you help me?
Thank you very much for your attention!