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.

CC3200-LAUNCHXL: Counting cycles or usec between events or interrupts TI RTOS

Part Number: CC3200-LAUNCHXL

Using TO RTOS and looking for a way to count cycles or usec between a event and GPIO interrupt.  I'm using a HC-SR04 ultrasonic distance sensor and need to measure the pulse width of its echo out.  I have one GPIO sending the trigger to the sensor board and have an interrupt on a 2nd PGIO pin.  I have confirmed the trigger pulse and echo pulse with a scope.  I've also confirmed the interrupt callback function is being called.  I would like to start a count via code after the trigger pulse steps and stop it on the interrupt.

Thanks

KS

  • Hi KS,

    For accuracy, I suggest you start a hardware timer in your first GPIO interrupt and then read the timer value (TimerValueGet) in your second interrupt. The timer drivers are available in the SDK driverlib folder.

    You can find all the timer options explained in the General-Purpose Timers section of the CC3200 Technical Reference Manual.

    Best regards,

    Sarah

  • Thanks Sarah,

    I guess I asked the wrong question.  The logic of using the interrupts isn't the issue, the real issue is more basic.  That's adding the timers to the rtos project.  I've included time.h in the main and have read thru the time.c & time.h notation and everything looks pretty straight forward.  However I don't see anything pointing to how or where the base address of a timer is defined.

    I've added the MAP_PRCMPeripheralClkEnable(PRCM_TIMERA0, PRCM_RUN_MODE_CLK); with the rest of the clocks, in rom_pin_mux_config and at least the complier doesn't throw an error.

    Your advice is appreciated,

    Kev

  • OK, I figured it out.  Ended up including 3 header files

    time.h, hw_types.h & hw_memmap.h

    Added the peripheral clock enable in rom_pin_mux_config.c & configured clock as a 1-shot count up timer.

    In the thread that generates the trigger pulse, the timer get's enabled

    In the GPIO pin interrupt callback function (triggered on a falling edge), the clock is disabled, the count is read and stored and the count is reset to 0

    Thanks for your help

    KS