Micro Seconds delay needed

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.xmece.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
7 posts / 0 new
Last post
Goluguri Sandee...
Offline
Last seen:10 months 2 weeks ago
Joined:2019-05-20 20:58
Micro Seconds delay needed

Hi All,

We have a sensor that needs delays in microseconds to be able to access it. Is there a function in the SDK or outside, where we can generate a 1-microsecond delay?

We got many delay functions but everything is in milliseconds. Can you please provide a solution for the same for freertos

Thanks and Regards,
Sandeep.

Device:
PM_Dialog
Offline
Last seen:3 hours 48 min ago
Staff
Joined:2018-02-08 11:03
Hi Sandeep,

Hi Sandeep,

Thanks for question online and for you interest in our BLE solutions. Unfortunately, setting micro-seconds delay is not possible, as the OS timer has 1.98msec ~= 2msec granularity. Please check the following macros in the FreeRTOSConfig.h

#define configSYSTICK_CLOCK_HZ 32768 #define configTICK_RATE_HZ ( ( TickType_t ) 512 ) #define TICK_PERIOD ((configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ))

Thanks, PM_Dialog

Goluguri Sandee...
Offline
Last seen:10 months 2 weeks ago
Joined:2019-05-20 20:58
I have a sensor that

I have a sensor that definitely needs a microsecond delay. without this, the sensor interface will not work. I have tested it on other microcontrollers too. Can you provide me a solution to this problem?

Thanks and Regards,

Sandeep.

PM_Dialog
Offline
Last seen:3 hours 48 min ago
Staff
Joined:2018-02-08 11:03
Hi Sandeep,

Hi Sandeep,

Let me check it internally and I'll get back to you shortly.

Thanks, PM_Dialog

PM_Dialog
Offline
Last seen:3 hours 48 min ago
Staff
Joined:2018-02-08 11:03
Hi Sandeep,

Hi Sandeep,

You can use the hw_clk_delay_usec() which is located in the hw_clk.h. This function gets the current clock source and adds delay of N uSecond. Since the you are using a sensor, the DA1469x should be in active mode, so that the system will be running with the 32MHz clock.

Thanks, PM_Dialog

Goluguri Sandee...
Offline
Last seen:10 months 2 weeks ago
Joined:2019-05-20 20:58
Hi,

Hi,

The documentation states that the

/**
* \brief Add delay of N usecs.
*
* \param[in] usec The number of usecs to wait for.
*
* \return void
*
* \warning The minimum delay is HW_CLK_DELAY_OVERHEAD_CYCLES in system clock ticks.
* The resolution is HW_CLK_CYCLES_PER_DELAY_REP in system clock ticks.
* The system clock tick is calculated after applying the AHB divider.
*/

#define HW_CLK_DELAY_OVERHEAD_CYCLES (72)
#define HW_CLK_CYCLES_PER_DELAY_REP (4)

Can you explain the calculation of the minimum delay?

Can it generate 1 us??

Thanks and Regards,

Sandeep.

PM_Dialog
Offline
Last seen:3 hours 48 min ago
Staff
Joined:2018-02-08 11:03
Hi Sandeep,

Hi Sandeep,

When running with the XTAL32M clock, the minimum delay that can be created is 3us. It’s not possible to create 1us running with 32MHz clock because the overhead of code execution is bigger than the delay. 1uS delay is achievable only when running with the PLL 96MHz. To do so, you should change the clock course to PLL before calling the hw_clk_delay_usec(1).

Thanks, PM_Dialog