2008-02-20 07:39:25     timing / udelay on BF561-ezkit

Document created by Aaronwu Employee on Sep 17, 2013
Version 1Show Document
  • View in full screen mode

2008-02-20 07:39:25     timing / udelay on BF561-ezkit

Michiel Verschueren (BELGIUM)

Message: 51338    Hi,

 

I'm new to U-Boot and the blackfin processors.

I'm using a ADSP-BF561 EZ-KIT Lite Evaluation System.

 

I want to write a simple program that prints a string, waits for a while, and then prints another string.

I have the following code:

 

#include <common.h>

#include <exports.h>

 

void test (int argc, char* argv[]) {

    app_startup(argv);

    printf("Line 1\n");

    udelay(1000);

    printf("Line 2\n");

}

 

The code compiles and links, so I suppose it's syntactically correct.

When I try to run this on the board, the two lines are printed, but there is no delay in between.

 

What am I doing wrong here?

 

Thanks in advance.

QuoteReplyEditDelete

 

 

2008-02-20 08:24:11     Re: timing / udelay on BF561-ezkit

Phil Wilshire (UNITED STATES)

Message: 51340    Hi,

 

udelay(1000) is a 1 milliSec delay

 

How are you measuring the time between the messages ?

 

Regards

  Phil WIlshire

 

QuoteReplyEditDelete

 

 

2008-02-20 09:22:48     Re: timing / udelay on BF561-ezkit

Michiel Verschueren (BELGIUM)

Message: 51346    Hi,

 

thanks for your quick reply.

 

I had mistakenly assumed that the delay was given in milliseconds. (Stupid of me: I should have known that the 'u' in 'udelay' has a meaning).

 

I have a new question though:

in trying to solve my problem, I have been looking at the interrupt generated by the blackfin's core timer. However, I couldn't find out how to register a function as an interrupt handler. It seems to me that this is possible for other architectures, but not for the blackfin: cpu/bf561/interrupts.c does not include an "irq_install_handler" or "irq_free_handler" function.

 

Am I missing something here? Or should I start implementing interrupt handling myself?

 

Thanks again,

 

Michiel

QuoteReplyEditDelete

 

 

2008-02-20 11:01:09     Re: timing / udelay on BF561-ezkit

Robin Getz (UNITED STATES)

Message: 51356    Michiel/Phil:

 

Just FYI - since I have been bitten by this once.

 

udelay (really_big_number) is a bad idea, since it will not work...

 

In linux-2.6.x/include/asm-blackfin/delay.h udelay is defined as:

 

static inline void udelay(unsigned long usecs)

{

        extern unsigned long loops_per_jiffy;

        __delay(usecs * loops_per_jiffy / (1000000 / HZ));

}

 

In most Blackfin based systems, loops_per_jiffy is around (based on dmesg)

 

root:~> dmesg | grep -i Hz

Processor Speed: 500 MHz core clock and 125 Mhz System Clock

root:~> dmesg | grep -i bogo

Calibrating delay loop... 995.32 BogoMIPS (lpj=1990656)

 

so, about 2,157 microseconds (4,294,967,295 / 1990656) is the largest number that you want to use with udelay, without causing some nasty 32-bit overflows on a system that is running at 500MHz. As you increase the speed, you get larger loops_per_jiffy, and the max number goes down.

 

This should actually get fixed...

 

-Robin

QuoteReplyEditDelete

 

 

2008-02-20 11:07:59     Re: timing / udelay on BF561-ezkit

Robin Getz (UNITED STATES)

Message: 51358    Oh, you are doing this from U-Boot?

 

Sorry I thought it was in the kernel - ignore my message. udelay in U-Boot is implemented differently, and should work for  udelay(max unsigned long)

 

-Robin

QuoteReplyEditDelete

 

 

2008-02-20 12:23:43     Re: timing / udelay on BF561-ezkit

Mike Frysinger (UNITED STATES)

Message: 51374    interrupts are not supported in u-boot ... you should poll hardware

QuoteReplyEditDelete

 

 

2008-02-21 03:34:37     Re: timing / udelay on BF561-ezkit

Michiel Verschueren (BELGIUM)

Message: 51408    OK, thanks

Attachments

    Outcomes