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.
Keywords:
Device:
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
Thanks, PM_Dialog
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.
Hi Sandeep,
Let me check it internally and I'll get back to you shortly.
Thanks, PM_Dialog
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
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.
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