Jump to content
Sign in to follow this  
rminnig

code generation error

Recommended Posts

Either way I write the commented line the generated code seems not to work properly.  The code should test the 'GO' bi tin ADCON0 and if the bit is not cleared (i.e. AD conversion not complete) then just stay in the while loop.  When the bit goes clear then the while statement should fail and jump out fo the loop.  What am I doing wrong.

I've included the generated assembly code, the original source code line is ;;;;;;;;;commented.

 

 

;;;;;;;; while (!(adcon0 & (0x01<<2))) {;} //wait for conversion complete

label_0000

movf _adcon0, W

andlw D'4'

btfss STATUS, Z

goto label_0001

;;;;;;;; chResult1 = adresh;

goto label_0000

label_0001

code continues...

 

 

;;;;;;;; while (adcon0 & (0x01<<2)) {;} //wait for conversion complete

label_0000

movf _adcon0, W

andlw D'4'

sublw 0

btfsc STATUS, Z

goto label_0001

;;;;;;;; chResult1 = adresh;

goto label_0000

label_0001

code continues...

Share this post


Link to post
Share on other sites
Guest Pavel
;;;;;;;; while (adcon0 & (0x01<<2)) {;} //wait for conversion complete

This is the correct code that will loop as long as bit 2 in adcon0 is set.

 

Regards,

Pavel

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...
Sign in to follow this  

×
×
  • Create New...