cancel
Showing results for 
Search instead for 
Did you mean: 

Delay in us

slapointe
Associate
Posted on October 16, 2006 at 07:38

Delay in us

9 REPLIES 9
slapointe
Associate
Posted on July 07, 2006 at 13:11

Does anyone has assembly ARM7 precise delay function as Delay10us (or between 1us and 100us)

Regards.

sany_as
Associate II
Posted on September 23, 2006 at 06:36

Hello simointe

were u ale to solve ur problem?

Even i too have the same question.I want to cll a delay.I can understand whats the clock cycle and machine cycle for each instruction.(STR710FZ2)

kindly help if u've the answer.

Thanks and regards

Sany

daweiy
Associate II
Posted on September 24, 2006 at 22:51

Try this routine. In my project, it's ok.

delayUS

; r0 is n US

; We assume cpu running in 48Mhz and code is located in RAM.

mov r1, #12 ;If CPU running in 16Mhz, change 12 to 4.

mul r0, r1, r0 ;Be careful in r0 overflow.

delayUS_loop

subs r0, r0, #1

bcs delayUS_loop

bx lr

[ This message was edited by: dawei on 25-09-2006 02:25 ]

sany_as
Associate II
Posted on September 27, 2006 at 09:34

hello!!!

can anybody tell me about the time taken to execute one instruction.I want to create a delay of say 4 microsecond.I am using STR710FZ2t6

Kindly help.

Regards

Sany

daweiy
Associate II
Posted on September 28, 2006 at 22:43

Quote:

On 27-09-2006 at 18:07, peterwrigley wrote:

One cycle will be used to execute a NOP.

The precise length of time will depend on the CPU operating frequency, which will depend on the PLL status and the crystal used.

The compiler may optimise out your instruction, which would give no delay as the function would not be executed. Overhead will be generated in calling the function and in returning from it. The precise overhead will depend on the calling conventions of your compiler (look at the disassembly listing).

Whether or not you are using Thumb mode may have an effect.

Personally I would configure the PLL then use a timer to generate a delay. You can then set a bit to flag to the rest of the application that ''something needs done'' or do small calculations in the interrupt routine. This is actually easier! Also note you can configure the hardware to automatically do things on counter matches; if you need to output a square wave (say to measure the frequency) the PWM, OPM or OCMP modes should be of use to you. These also have the advantage that the CPU does not intervene so the value you load into the timer module will have a direct relationship with the length of any output pulse.

sany_as
Associate II
Posted on October 13, 2006 at 01:55

So does it mean that if i configure the clock so that APB2 recieves a freq of 48MHz then each instruction requires 1/48th of the microsecond to execute an instruction (IN ASSEMBLY)...??##@@

Simultaneously can i configure the three different clocks reaching APB1,APB2 and MCLK, dynamically with respect to my need....

Kindly respond

Regards

Sany

pete3
Associate II
Posted on October 13, 2006 at 10:57

Yes and yes, nice isn't it?

You can dynamically configure the clock to any mix of frequencies you like. This is not necessarily a good idea in normal operation, but during a low power state you will find that the core clock has stopped and is waiting for an interrupt, which usually will come from one of the APB peripherals.

P46 of the STR7 reference manual might help you here. Also note that branches may require up to three cycles to execute as the pipeline is flushed. More info (p34 of 360):

http://www.arm.com/pdfs/DUI0068B_ADS1_2_Assembler.pdf

If you are new to the architecture AND you're programming in assembly, you're braver than me! I suggest you look at the ST C libraries for the chip. Even if you are working in assembly they may clear up some problems later on.

sany_as
Associate II
Posted on October 14, 2006 at 09:59

Thank you very much for the reply...and valuable suggestion..

pete3
Associate II
Posted on October 16, 2006 at 07:38

You're welcome 🙂