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.
Hello TI-Team,
I want to configure cmpss using the c2000Ware to trigger a counter if the value in cmpss input is higher than the defined value in order to count events over time. In case I have more than x events in time y, I need to react. I use cmpss1 on pin 18.
I started with the example code:
CMPSS_configDAC(CMPSS1_BASE, CMPSS_DACREF_VDDA | CMPSS_DACVAL_SYSCLK | CMPSS_DACSRC_SHDW); CMPSS_setDACValueHigh(CMPSS1_BASE, 2048); // // Configure the output signals. Both CTRIPH and CTRIPOUTH will be fed by // the asynchronous comparator output. // CMPSS_configOutputsHigh(CMPSS1_BASE, CMPSS_TRIP_ASYNC_COMP | CMPSS_TRIPOUT_ASYNC_COMP);
Is there any example for this particular case.
So how do I configure the xbar to connect cmpss1 and xint5? I would like to avoid to count the events manually since they are quite high frequent in case they occur, is there an event count register which I can read out or which way is the best to count my events?
Thanks in advance.
Hi Jan,
The CMPSS doesn't have an inbuilt event counter but I think it will be better for you to use the ECAP for this. You can setup the ECAP to timestamp your events. For this particular case, you don't really care about the time information and rather if the event happened. Since each ECAP has 4 events, you can utilize this to buffer the events before you respond.
At the end of 4 events, the ECAP will fire off an interrupt to the CPU where you can accumulate it to your event buffer and proceed accordingly. If you prefer a more hands-off approach and have the CLA available, instead of interrupting the CPU after 4 events, you can trigger a CLA task that will do this accumulation in the background and notify the CPU once it reaches a certain limit that you specify.
One thing to keep in mind with this approach is that even though the ECAP counter is quite long at 32-bits, it can still overflow. If this is a possibility for your application, you can probably balance how many events to capture at a time before triggering the CLA for the accumulation. For instance rather than capturing 4 events at a time, maybe you can capture 2 or 1 instead. We have ECAP and CLA examples in C2000Ware that you can add your code snippet above to.
Maybe my formulation was wrong. I do not want to trigger an interrupt, I just want to read out the counter. So Is it possible to read out just the counter of the ECAP every x milliseconds and see how many events occured and reset the counter again? I need to do the same via a GPIO pin which needs to be connected to a counter counting rising edges (up to 10 MHz). Here again it would be ideal if I just could read out the ecap counter value every x milliseconds and if the counter is > x, I react. I do not want to create any overhead for the CPU or for the CLA. The CLA cannot be bothered with counting high frequent events. The c2000 ware seems not to offer this functionality.
At least I was able to implement a first example calling a an ISR and count the events. I still need to evaluate if I configured everthing right and the frequency is fitting to my test input signals.
Furthermore, I need to do something similar with an GPIO input. Is there a better solution to count these high frequent events than using the ecap? Again I do not want to waste time in an interrupt. Does the tms320f280049c does not support event counting?
Jan,
Maybe I didn't completely understand your original question. The ECAP, CMPSS, etc don't have inbuilt hardware event counters so some software would have had to be involved.
However, I discussed this with our CLB expert and he mentioned the CLB should be able to do what you are looking for in hardware. I'll let him reply with more details.
You can definitley count edges in CLB. You can enable the CLB Input filter to capture RISING or FALLING edges. Then you can connect the input signal to the enable of the CLB COUNTER 0 and count the edges.
Nima
Is there an example how to route the cmpss to the clb? I so far did not use the CLB module. Furthermore, a simple example to diretly link the GPIO input into the CLB would also be perfect.
When I study the manual it seems I could diretly link cmpss signal inot the clb.
It is importaint to mention, that I cannot use an uncertified tool in my company, therefore the clb tool cannot be used. It feels like that two really easy tasks, counting cmpss high events and GPIO rising edges are quite complex through the complexity of the clb module, at least for me first time using this module.
Thanks in advance.
You have a CLB XBAR. You select your signal source inside your CLB XBAR and take it out on a AUXSIGx. Then in CLB Global and LOCAL mux you can select input signals to the CLB. AUXSIGx can be selected in the global/local mux.
Nima