Hi,
A customer has a use case as below.
The plan is to use one IO in sensor controller to measure the frequency of PWM which is the range of 100Hz~500KHz.
Does TDC support 500KHz?
They have tried GPIO and Timer event trigger. The counter was increased for each falling edge, then it counts the number of edge while one second timer expired.
However "event handle B" below only run less than 10 times in one second.
Would you let me know if there is any issue in the following code? Thanks!
Initializing:
// Do not drive the reference high gpioClearOutput(AUXIO_O_LED); gpioClearOutput(AUXIO_O_LED_2);
////// Schedule the first execution evhSetupTimer1Trigger(0, 1, 5);
////// Schedule the first execution //evhSetupTimer0Trigger(1, 1, 6); evhSetupGpioTrigger(1, AUXIO_I_BTN_15, BUTTON_PRESSED, EVH_GPIO_TRIG_ON_EDGE); |
event handle A (One second timer):
state.ledStatus ^= 1; if(state.ledStatus > 0){ gpioClearOutput(AUXIO_O_LED); }else{ gpioSetOutput(AUXIO_O_LED); } output.fallingEdgeNewCnt =output.fallingEdgeSumCnt - output.fallingEdgeCnt; output.fallingEdgeCnt =output.fallingEdgeSumCnt; // Schedule the next execution // 1 sec evhSetupTimer1Trigger(0, 1024/1, 2); |
event handle B (Detect GPIO falling edge):
state.led2Status ^= 1;
if(state.led2Status > 0){ gpioClearOutput(AUXIO_O_LED_2); }else{ gpioSetOutput(AUXIO_O_LED_2); }
output.fallingEdgeSumCnt = output.fallingEdgeSumCnt + 1;
// The "Event Handler Code" state machine shall first wait for the button to be pressed evhSetupGpioTrigger(1, AUXIO_I_BTN_15, BUTTON_PRESSED, EVH_GPIO_TRIG_ON_EDGE); |
Regards,
Yonghua