Other Parts Discussed in Thread: OMAPL138
Hi
We are using Ecap peripheral of OMAPL138 for counting and finding Absolute time of external pulses.With this we are facing some issues.
Case1:
Ecap Initialization done for CAP mode Absolute time,Rising edge Trigger
Simple polling mode is used to count pulses and its time.Code snippet is given below.
Input given for Ecap is 1Hz pulse with 50% duty cycle.It is observed that for even 5- 7 pulses, the array of 10 (which is used to store time stamp) is filled with around 20-50% error value
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
void Ecap_Init (void)//polling
{
PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_ECAP0_1_2, PSC_POWERDOMAIN_ALWAYS_ON,
PSC_MDCTL_NEXT_ENABLE);
Ecap2_PinMuxSetup();
ECAPCapeEvtPolarityConfig(SOC_ECAP_2_REGS,0,0,0,0);//use zero for Rising edge..wrong comment is given in ECAP driver library
ECAPCaptureEvtCntrRstConfig(SOC_ECAP_2_REGS,0,0,0,0);
ECAPCaptureLoadingEnable(SOC_ECAP_2_REGS);
ECAPPrescaleConfig(SOC_ECAP_2_REGS,0);//No prescale is used
ECAPOperatingModeSelect(SOC_ECAP_2_REGS,ECAP_CAPTURE_MODE);
ECAPContinousModeConfig(SOC_ECAP_2_REGS);
HWREGH(SOC_ECAP_2_REGS + ECAP_ECCTL2) |= 0x0080;//Disable SYNC OUT Signal
ECAPCounterControl(SOC_ECAP_2_REGS,ECAP_COUNTER_FREE_RUNNING);
}
main()
{
Ecap_Init ()
while(1)
{
u32EcapStatus= (HWREGH(SOC_ECAP_2_REGS + ECAP_ECFLG));
if(u32EcapStatus & ECAP_CEVT1_INT)
{
u32Event1_Time=ECAPTimeStampRead(SOC_ECAP_2_REGS,ECAP_CAPTURE_EVENT_1);
HWREGH(SOC_ECAP_2_REGS + ECAP_ECCLR) = HWREGH(SOC_ECAP_2_REGS + ECAP_ECCLR) | ECAP_CEVT1_INT;//clr Flag
f32TimeStamp[Buffercnt++] = (float)u32Event1_Time*(1/(float)ECAP_MODULE_CLK); //ECAP_MODULE_CLK is 150Mhz
if(Buffercnt==10)
{
Buffercnt=0;
}
}
}
}
//Result from Watch window for a input of 1Hz with 50% duty cycle.We placed break point on Buffercnt ,when it reaches to 10
f32TimeStamp float[80] [24.4922981,24.5874634,24.587471,25.0875397,25.5874767...] 0x11819B00
[0] float 24.4922981
[1] float 24.5874634
[2] float 24.587471
[3] float 25.0875397
[4] float 25.5874767
[5] float 26.5874882
[6] float 27.0875664
[7] float 28.0875759
[8] float 28.587513
[9] float 0.454473346
Note:-Unit of these values is Second
Note:-We found some bugs in Ecap driver library given by TI,So in some places we used our own code
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
It seems that it is reentering in to the loop for a single pulse even after clearing Flag .
We followed configuration guidelines given in the Reference manual strictly (Ref page No 451 of OMAPL138 Reference Manual) and we verified actual configuration using Watch window for SFR
Please let me know anything I missed in the Initialization of Ecap
Tools & Parts used
1.Processor used:-OMAPL138BZWT
2.CCS Version:-7.3.0.00019
3.Compiler:-TI v8.2.2
4.Debugger:-XDS200
5.Driver Library:-OMAPL138_StarterWare_1_10_04_01
6.Target Board:-Our Own board
7.Ecap used:- Ecap1 or Ecap2
8.Core used:- DSP
Regards,
Satheesh