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.

Delay function in millisecond for LCD Display

Other Parts Discussed in Thread: OMAPL138, SYSBIOS, AM3359

Hi,

In the example of liddDisplay.c (Starterware OMAPL138 in DSP), there is only general delay loop. I would like to generate a more precise delay (for example in millisecond) for LCD Display.

How can I create such delay function based on CPU clock?

Mok

  • Hello Kim,

    You could use the delay provided as utility function.

    The delay function uses an argument to provide the count as milliseconds.

    Please refer to Utils/delay.c for more information.

    -Vinay

  • Hello Vinay,

    I think this is the function that I am looking for. Though, I have few problems on using this function, hope you can advice:

    1. Can't find a source file at "C:/GForge/starterware/dev/OMAPL138_StarterWare_1_10_03_03/platform/evmOMAPL138/sysdelay.c" 
    • The delay() function  in delay.c is wrapper API. The source code is at sysdelay.c.
    • My installation of Starterware is at location: C:\ti\OMAPL138_StarterWare_1_10_03_03
    • I have "Add Files" of sysdelay.c to resolve this issue. Do you have any idea where to edit the search location?
    • The code doesn't enter TimerIsr() [delay stuck in while(flagIsrCnt) in Sysdelay()]
    • delay() linked to Sysdelay(), which using Timer (Interrupt-based). Seems like DelayTimerSetup() need to be added (to setup the Timer interrupt)?

    Regards,

    Mok

  • Hello Kim,

    Please add the file from the following location.

    C:\ti\OMAPL138_StarterWare_1_10_03_03\platform\evmOMAPL138\sysdelay.c

    DelayTimerSetup() has to be called once before using delay() to configure timer 0.

    After the configuration you can use the function :

    void delay(unsigned int milliSec)

    The delay configures the timer period to the value passed by user and generates the interrupt after the period is elapsed.

    Typical Usage:

    /* To be called once during initialization */
    DelayTimerSetup();
    .
    .
    .
    delay(1000); /* for 1000 msec delay */

    I suggest you add the following change for clearing the timer count before you use the delay.

    In file C:\ti\OMAPL138_StarterWare_1_10_03_03\platform\evmOMAPL138\sysdelay.c,

    Before change:

    void Sysdelay(unsigned int milliSec)
    {

    TimerPeriodSet(SOC_TMR_0_REGS, TMR_TIMER12, (milliSec * TMR_PERIOD_LSB32));

    After change:

    void Sysdelay(unsigned int milliSec)
    {
    TimerCounterSet (SOC_TMR_0_REGS, TMR_TIMER12, 0);
    TimerPeriodSet(SOC_TMR_0_REGS, TMR_TIMER12, (milliSec * TMR_PERIOD_LSB32));

    Please let me know if this answers your post

    Regards,
    Vinay

  • Hi Vinay,

    Thanks for the information. On top of that, Global Interrupt Setup, which are missing, need to be added as highlighted BLUE  below (I used DSP):

    static void AintcTimerIntrSetUp(void)

    #ifdef _TMS320C6X

    /* Initialize the DSP */
    IntDSPINTCInit();

    /* Register the Timer ISR */
    IntRegister(C674X_MASK_INT10, TimerIsr);

    /* Set the channel number for Timer interrupt, it will map to IRQ */
    IntEventMap(C674X_MASK_INT10, SYS_INT_T64P0_TINT12);

    /* Enable timer interrupts in AINTC */
    IntEnable(C674X_MASK_INT10);

    /* Enable DSP interrupts */
    IntGlobalEnable();

    Thanks.

    Regards,
    Mok

  • Hello Vinay,

    I am working with ICE AM3359 and using CCS v6. I tried to load audio buzzer example which uses a delay function, it got build successfully but I dont get any output from the buzzer. Could you please guide me if it is due to delay function. Below i am including my console log. I used am335x_sysbios_ind_sdk_1.1.0.8.0842.Log.txt