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.

CC2340R5: Short Pause with usleep function (< 1millisecond)

Part Number: CC2340R5

Tool/software:

Hello,

I want to generate a short pulse (1ms) on output to reset an external peripheral.

I used usleep(1000) command between output OFF and output ON.

It doesn't work.

Any idea ?

Thanks.

  • Hello Thierry,

    I used usleep(1000) command between output OFF and output ON.

    It doesn't work.

    Can you specify what exactly doesn't work?  Can you provide additional debug information and logic analyzer/oscilloscope screenshots of your external peripheral pins?

    I modified the empty code to use usleep(1000); and got the following results

    Granted, there is the delay ceiling to consider in the usleep function:

    xDelay = (usec + TICK_PERIOD_USECS - 1) / TICK_PERIOD_USECS;

    This becomes xDelay = (x + 1000 - 1) / 1000, and since the remainder of integer values are floored then values of 1000 or under will result in an xDelay of one.  Thus usleep is not the most dependable for less than 1000 (1 ms) of sleep, although it does still provide a short 2.8 ms delay.

    If this granularity is unacceptable then you can try the driverlib CPUdelay or DPL ClockP_usleep (shown in example below after adding the proper #include <ti/drivers/dpl/ClockP.h>).

    Regards,
    Ryan

  • I put a breakpoint on usleep(1000) line. And when I click on "Step Over", the software is frozen.

    When I click on Suspend, the software is blocked here :

    I tried with ClockP_usleep function and the result is same.

    For your information, I call this function "sleep"  before call vTaskStartScheduler. May be clock used by this function is not running ?

    Have you another idea ?

    Thank you for your support.

  • For your information, I call this function "sleep"  before call vTaskStartScheduler. May be clock used by this function is not running

    Please apply your code inside the application task after it has been started.

    Regards,
    Ryan