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.
Tool/software: Code Composer Studio
Hi all,
I try to debug the demo program of "ecap_ex2_capture_pwm.c" based on C2000ware. But I found that the time stamps captured on EVENT1/2/3/4 are different. The debug information is just like below:
ECAP_setEventPolarity(ECAP1_BASE, ECAP_EVENT_1, ECAP_EVNT_FALLING_EDGE);
ECAP_setEventPolarity(ECAP1_BASE, ECAP_EVENT_2, ECAP_EVNT_RISING_EDGE);
ECAP_setEventPolarity(ECAP1_BASE, ECAP_EVENT_3, ECAP_EVNT_FALLING_EDGE);
ECAP_setEventPolarity(ECAP1_BASE, ECAP_EVENT_4, ECAP_EVNT_RISING_EDGE);
cap1Count = ECAP_getEventTimeStamp(ECAP1_BASE, ECAP_EVENT_1);
cap2Count = ECAP_getEventTimeStamp(ECAP1_BASE, ECAP_EVENT_2);
cap3Count = ECAP_getEventTimeStamp(ECAP1_BASE, ECAP_EVENT_3);
cap4Count = ECAP_getEventTimeStamp(ECAP1_BASE, ECAP_EVENT_4);
Based on the code above, I think that cap1Count shoud have the same time stamp value with cap2Count, cap3Count and cap4Count.
But cap1Count sometimes 4 more than other capture counters, or 4 less than other counters.(cap2Count/cap3Count/cap4Count).
I don‘t know what happened. Please help me with it.
Thanks!
Hi,
The time stamp capture on Event1, Event2, Event3 and Event4, should be different, meaning cap1Count, cap2Count, cap3Count and cap4Count should all have different values. I am not sure why you see same values for cap1Count, cap2Count and cap3Count.
Have you modified the C2000Ware example? When you run the example as it is do you see different values or same values?
Regards,
Nirav
Hi Lei,
What you are seeing is not unexpected. You will notice that the original example doesn't have "cap1Count" variable. This is because in the example, the ECAP is configured in delta capture and one-shot mode. The ECAP resets the counter after every event but when it captures Event4, it also stops counting until it’s re-armed. Because the ECAP stopped counting after Event4, Event1 doesn’t have a good reference point so whatever you read from “cap1Count” won’t make a lot of sense.
Let us know if it’s not clear.
Hi Frank,
There are four event ,aka EVENT_1/EVENT_2/EVENT_3/EVENT_4, for one ECAP module. If I only want to use two of them, e.g. EVENT_1 and EVENT_2, how to configure it? I found that EVENT_3 and EVENT_4 also take effect if only I configured EVENT_1 and EVENT_2.
Thanks.
Hi,
What is the used case here? Are you using the ECAP in one-shot mode or continuous mode?
You can stop the counter in one-shot mode or wrap the counter in continuous mode using ECCTL2.STOP_WRAP register.
Regards,
Nirav
Lei,
To expand on Nirav's response: Yes, the ECAP can capture a maximum of 4 events. You don't have to use all 4 events but you do have to use them starting from event 1. For example, if you only need 2 events, you will need to configure and use event1 and event2. You can't for instance use event3 and event4 and skip event1 and event2.
Let us know if it's not clear.