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.
Hi,
Could you suggest any existing Timer/Clock function to get elapsed time between rising and falling edge of an interrupt?
I am trying to distinguish short (less than 1 sec ) and long button presses (1 sec ).
I tried with Clock_getTicks() and checking for LONG_PRESS_DURATION (10E8) for 1 sec
(as 1 count will be 10 nano sec with 100MHz system clock)
void gpioInterruptHandler(void) { if ((false == modeBtnrisingEdgeDetected) && GPIO_readPin(gpioButton01)) { modeBtnrisingEdgeDetected = true; modeBtnrisingEdgeTime = Clock_getTicks(); } else if ((true == modeBtnrisingEdgeDetected) && !GPIO_readPin(gpioButton01)) { timeDiff = Clock_getTicks() - modeBtnrisingEdgeTime; System_printf("System time\n", (ULong)timeDiff); if (timeDiff < LONG_PRESS_DURATION) { GPIO_togglePin(gpioLED01); } else { GPIO_togglePin(gpioLED04); } modeBtnrisingEdgeDetected = false; modeBtnrisingEdgeTime = 0; } Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1); }
I did not initialize any clock and was trying to use the one that is configured by default which shows tickperiod as 1000 and timer period as 2500
It doesnt work with this, could you suggest alternatives?
Thanks,
Rashmitha
The ECAP peripheral is a good way to measure the time between edges on a pin. Have you considered that?
I think your current approach is doable though. I assume you have the XINTs configured to trigger on both rising and falling edges? In what way isn't it working? What have you done to debug it?
Note that the SYS/BIOS Clock tick period is in terms of microseconds, so 1000 is 1 ms--it's not equivalent to a SYSCLK tick.
Whitney
Hi Whitney,
I am trying to create a clock with 100 micro secs period. Could you help me with the calculation to find how much should be the value of clkParams.period?
As per my calculations, I think it should be 10 but when I try on the board I have to press for 2-3 secs, I am expecting a 1 sec response
I am checking time difference between falling and rising edge to be as #define LONG_PRESS_DURATION_US 1000000U // 1 sec
var clkParams = new Clock.Params(); clkParams.period = 10; //100 us clkParams.startFlag = 1; var myClk = Clock.create('&clk0Fxn', 10, clkParams);
Thanks,
Rashmitha
Clock periods are based on the BIOS tick which as I said in my previous message is set to 1 ms by default, so period = 10 is 10 ms. If you want something based on a SYSCLK tick, use a Timer instead of a Clock.
Whitney
Is it possible to configure Clock for 100 micro sec period?
clkParams.period doesn't take decimal values. Then how should I configure it?
Thanks,
Rashmitha
You would need to change the system tick period (Clock.tickPeriod) to get that kind of granularity in the Clock module. It's generally not recommended to configure the system tick to execute at such a high rate though. There's some discussion on this subject here:
Whitney