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 in uboot

HI

I am trying to toggle  led on 7th pin of port 1 in uboot for dm8148  .        board/ti/ti8148/evm.c.

but now the problem i am getting is, my delay function is not working in uboot can you please tell me how to provide delay in uboot so that i can check the blinking of the led.

my code is below:

uu_delay(unsigned int cnt)

{

   unsigned int i=0,j=0;

   for(i=0;i<cnt;i++)

     for(j=0;j<0x9ffffff;j++);

}

void gpio_pad_config_mux(void)

{

unsigned int i, val;

printf("Enabling the 7th pin of port 1 as output\n");

while(1)

{

val=__raw_readl(GPIO1_DATAOUT);

val&=0xffffff7f;

__raw_writel(val,GPIO1_DATAOUT);

printf("LEd ON\n");

       uu_delay(0xffffff);

       uu_delay(0xffffff);

       uu_delay(0xffffff);

val=__raw_readl(GPIO1_DATAOUT);

val|=0xffffffff;

__raw_writel(val,GPIO1_DATAOUT);

printf("LED OFF\n");

       uu_delay(0xffffff);

       uu_delay(0xffffff);

       uu_delay(0xffffff);

}

}

BR

  • Hi Abhishek,

    Abhishek Kumar47 said:
    uboot for dm8148  .        board/ti/ti8148/evm.c

    Abhishek Kumar47 said:
    my delay function is not working in uboot

    Abhishek Kumar47 said:
    delay(unsigned int cnt)

    Abhishek Kumar47 said:
     uu_delay(0xffffff);

    You are creating/defining delay function with name delay(), but then use uu_delay()?

    In u-boot/board/ti/ti8148/evm.c we have delay function ready for use (no need to create/define your own):

    /*
     * spinning delay to use before udelay works
     */
    static inline void delay(unsigned long loops)
    {
        __asm__ volatile ("1:\n" "subs %0, %1, #1\n"
            "bne 1b" : "=r" (loops) : "0"(loops));
    }

    delay(0xFFFF);

    udelay(100000);

    You can use delay(unsigned long loops) where loops are used to generate the delay and udelay(unsigned long usec) where seconds are used to generate the delay.

    Regards,
    Pavel