Jump to content

Recommended Posts

What's wrong here? The CALL to Update_Timer() never returns.

 

Looking at the asm file, the code generated loops forever

back to label29.

 

Easy to see that the second loop would work.

 

Where is my error? Can anyone help?

 

**********Code

 

void Update_Timer()

{

for (x=0;x<200;x++)

{

for (t=0;t<11;t++)

{

delay4M_100_us();

UpdateDisplay();

}

}

}

 

 

****************ASM file

void Update_Timer()

 

{

for (x=0;x<200;x++)

01C5 1283 BCF STATUS, RP0

01C6 1303 BCF STATUS, RP1

01C7 01B7 CLRF gbl_x

01C8 label29

01C8 30C8 MOVLW 0xC8 <----

01C9 0237 SUBWF gbl_x, W ^

01CA 1803 BTFSC STATUS,C ^

01D7 0AB7 INCF gbl_x, F ^

01D8 29C8 GOTO label29 ---------- >^

 

{

for (t=0;t<11;t++)

01CC 01B5 CLRF gbl_t

01CD label30

01CD 300B MOVLW 0x0B

01CE 0235 SUBWF gbl_t, W

01CF 1C03 BTFSS STATUS,C

01D0 29D3 GOTO label31

01D1 1FB5 BTFSS gbl_t,7

01D2 29D7 GOTO label32

01D3 label31

01D5 0AB5 INCF gbl_t, F

01D6 29CD GOTO label30

01D7 label32

 

{

delay4M_100_us();

01D3 201C CALL delay4M_10_00017

 

UpdateDisplay();

01D4 209A CALL UpdateDisp_00018

 

}

}

}

01CB 0008 RETURN

Share this post


Link to post
Share on other sites

Ive been caught by this one before

 

observe the addresses of the instructions

01C8 label29

01C8 30C8 MOVLW 0xC8 <----

01C9 0237 SUBWF gbl_x, W ^

01CA 1803 BTFSC STATUS,C ^

01D7 0AB7 INCF gbl_x, F ^

01D8 29C8 GOTO label29 ---------- >^

Share this post


Link to post
Share on other sites

Your nested for loops work for me.

 

The listing file may not produce sequential code addresses but if you follow the instructions using sequential addressing it does work.

 

Cheers

 

Reynard

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...