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.

how can I create a wait or a sleep to implement in dsp f28335(CCS 3.3)??

Other Parts Discussed in Thread: CONTROLSUITE

Hello experts,

I have a query in dsp f28335. I am generating a square wave using the DSP and am using code composer 3.3 version. 

I am setting the bit of one of the registers (GPIO49 say) as 1 and calling a delay loop and clearing it and calling the same delay loop.

I am setting the value of frequency and duty cycle as 50%.

Is there any way I can use wait(delay1) and wait(delay2) or sleep(delay1) or sleep(delay2) or something so that I can achieve 50% duty cycle. the value of delay1 and delay2 are equal..

value of delay 1 and 2 are 5.99*1e^-5

Regards,

Aravind Hariharan

  • Hi Aravind Hariharan,

    Sure you can implement delay loop to implement a duty cycle on a GPIO.
    Please refer to GPIO Toggle example in controlSuite.
    If you do not already have controlSUite please download the same from http://www.ti.com/tool/controlsuite  

    -Bharathi

  • Hello,

    Am new to this. Can you spot me where exactly can I find the delay loop in examples so that I can use those.?
    It will be good if you can copy/paste the code for me.
    I have CCS 3.3 installed already.

    Can I use #include<stdio.h> and #include<stdlib.h> and use the wait and sleep command or I can only use the delay command?

    Thanks and Regards,
    Aravind Hariharan.
  • Hello,

    I have added DSP2833x_usDelay.asm in the project and included the header "DSP2833x_Examples.h".
    I am doing the below in my code:

    while(1)
    {
    GpioDataRegs.GPBSET.bit.GPIO49 = 1;
    delay_loop(d1,D,F);
    DELAY_US(d1); // inbuilt function
    GpioDataRegs.GPBCLEAR.bit.GPIO49 = 1;
    DELAY_US(-(d2));//inbuilt function
    delay_loop(d2,D,F);
    }
    Am not achieving the square wave which I needed if I use the inbuilt Delay US.

    Alternatively, I wrote a delay loop for the following input values:
    long F = 100000;
    float D = 0.5;
    long double d1,d2;
    d1 = D/F;
    d2 = (1/F)-d1;

    My delay loop function is the below:

    void delay_loop(long double end, float D,long F)
    {
    long double i = 0.000001;
    while(i <end)
    {
    asm(" NOP");
    EALLOW;
    SysCtrlRegs.WDKEY = 0x55;
    SysCtrlRegs.WDKEY = 0xAA;
    EDIS;
    i = i + (0.75/F);
    }
    }

    I get the required answer but the problem is if I change the values of F and D i have to change the values of I in the loop.

    Please suggest!!!
    Regards,
    Aravind Hariharan