Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Assembly instruction cycle for 3 counters delay loops

Status
Not open for further replies.

BLaacK89

Newbie level 4
Newbie level 4
Joined
Oct 29, 2014
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
46
Hello forum members,

I need to know formula of this loop.

Code:
DELAY					
		MOVLW H’FF’(M)				1
		MOVWF SAYAC1				1
Loop1					
		MOVLW H’90’(N)				1XM
		MOVWF SAYAC2				1XM
Loop2					
		MOVLW H’50’(D)				1xNXM
		MOVWF SAYAC3				1XNXM
Loop3		
		DECFSZ SAYAC3,F			(D+1) .N.M
		GOTO	Loop3					(2.D-2) .N .M
                DECFSZ SAYAC2,F			(N+1) .M
		GOTO	Loop2					(2.N-2) . M
                DECFSZ SAYAC1,F			M+1
		GOTO	Loop1					2M-2

RETURN							2

Formula = 3+4.N+3.M.N ?

why the formula is not true ?
 

Hi,

A software delay loop is based on the number of instruction to complete that loop.

Does your formula account for the fact that not all of those instruction are completed in one machine cycle, some like the goto and decf may need 2 machine cycles. ( see the chips data sheet - section Instruction Set Summary.)

The loop as it stands in just short of 9 million instructions on a Pic16F.
 

Thanks for helping,

I used pic16f887.

I need formula cause of I would like to flexibly projects.
 

hello,

your formula is wrong.. because you are using external loop
and reinitiate value inside the loop..
so global is more than M*N*D ..etc ..

if preferre to use this, from Myke Predo 1997 !
very universal

Delay_asm.jpg

at 4MHz FOSC , cycle=1µS
mini is with values count1=1,count2=1,count3=1 => 6µS
maxima is with values 255 ,255,255 => 83.559 secondes !!!
Formula inside the picture...
 
Hi,

Think that chart paulfjujo shows does just about everything, but for basic delays I find this calculator as easy as it gets.

**broken link removed**
 
@wp100

**broken link removed**

Please forget easy delay generators .

I've tried a lot of generator. all generators are different . I am annoyed about this situation.

So. I need more maths operation for truely delay loops.

@paulfjujo

Let me match our math operation .

Let's write the number of the instruction against the code

Code:
                DELAY					
		MOVLW H’50’				1
		MOVWF Count1				1
Loop1					
                DECFSZ Count1,F			        2+Count1-1  =1+count1
		GOTO	Loop1					2x(count1-1)= 2xcount1  -2 

RETURN							2

total = 2 + 1+count1+2count1 -2 +2
total = 3+3count1
total = 153instruction cycle .

please do math operation by same way.
 
Last edited:

@wp100

**broken link removed**

Please forget easy delay generators .

I've tried a lot of generator. all generators are different . I am annoyed about this situation.

So. I need more maths operation for truely delay loops.

@paulfjujo

Let me match our math operation .

Let's write the number of the instruction against the code

Code:
                DELAY					
		MOVLW H’50’				1
		MOVWF Count1				1
Loop1					
                DECFSZ Count1,F			        2+Count1-1  =1+count1
		GOTO	Loop1					2x(count1-1)= 2xcount1  -2 

RETURN							2

total = 2 + 1+count1+2count1 -2 +2
total = 3+3count1
total = 153instruction cycle .

please do math operation by same way.


Hi,

The Decfsz is only 1 cycle when used in that mode .

H'50' = decimal 80

Have you tried using MPlabs SIMulator and Stopwatch, you can Single Step though each instruction or use breakpoints to start and stop code between certain points.
The Stopwatch increments with each instruction.
 

Attachments

  • 000082.jpg
    000082.jpg
    16.4 KB · Views: 148
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top