Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

I'm trying to calculate the period between falling edge and rising edge interrupt in interrupt callback routine.

The period is short as several usec.

Do someone know how to get the CPU tick timer? or tick timer API that has resolution of micro second?

Thank you,

0 Likes
1 Solution
asridharan
Employee
Employee
10 comments on KBA 5 comments on KBA First comment on KBA

See bleapputils.h:

/// This function gives a microsecond clock; this is a 16-bit counter,

/// counting up.

/// \return The 16-bit counter value, which rolls over every 65.5 ms.

UINT16 bleapputils_currentTimeUs(void);


EDIT:


Sorry, the earlier method will not be accurate on the 2073* family of chips. Use these instead (all based on the Bluetooth clock, with min resolution of 312.5uS; there is no timer with a shorter resolution accessible from the application):

/// This function returns the current native Bluetooth clock; this

/// counter is 28 bits, and ticks every 312.5 us and is adjusted for

/// drift through sleep, etc. To compute differences and times elapsed,

/// use bleapputils_diffNativeBtClks() or bleapputils_BtClksSince().

/// \return the counter value.

/// \return The current BT clock value.

UINT32 bleapputils_currentNativeBtClk(void);

/// This function computes the signed difference between two BT

/// clock instants. The general "garbage-in garbage-out" principle

/// applies, so clocks must be from the same piconet, must be valid when

/// they are taken, etc. BT clock is 28 bits only and cannot be relied upon when

/// timings in the hours are desired.

/// \param from is the "from" time.

/// \param to is the "to" time.

/// \return the signed difference (to - from); positive if "to" is after "from",

/// negative otherwise.

INT32 bleapputils_diffBtClks(UINT32 from, UINT32 to);

/// This function computes the time elapsed since "before", in BT

/// clocks. This functions handles rollovers. Clock resets will cause

/// a large value to be returned.

/// \param before is the previous counter value, as was returned by

/// hiddcfa_currentNativeBtClk().

/// \return the time elapsed, in BT clocks (312.5 us).

UINT32 bleapputils_BtClksSince(UINT32 before);

View solution in original post

5 Replies