Jump to content
Sign in to follow this  
lutcho

Incorrecp bank switching

Recommended Posts

I was writing a code to write to the EEPROM on a PIC16F876A. The line (just an example, it happens in other lines also)

 

while(eecon1 & 2); //WR test

 

was compiled as:

 

label_0111

bsf STATUS, RP0

bcf STATUS, RP1

btfss _eecon1, 1

goto label_0112

goto label_0111

label_0112

 

Well, my question is: Since the eecon1 register address is 18C (bank 3), shouldn't the page switches be both set??

Share this post


Link to post
Share on other sites
Guest Pavel

Here is what I've got for same code:

;;;;;;;;while(eecon1 & 2); //WR test
label_0001
bsf STATUS, RP0
bsf STATUS, RP1
btfss _eecon1, 1
goto label_0002
;;;;;;;;
;;;;;;;;
;;;;;;;; //Hardware Initialization
;;;;;;;;
;;;;;;;; disable_interrupt( 0x0007 );
goto label_0001

 

Check if you have the correct target set.

 

Regards,

Pavel

Share this post


Link to post
Share on other sites

Interesting:

If I create a new project, the compilation is like yours.

But if I open my original project, even if I select the target as 16F876 (or 16F876A) (includes are correct) it compiles just like my first example.

The project was originally written for 16F628 and recently "upgraded" to 876A.

 

Copying and pasting the code into new files corrected the problem. Is there a bug around???

 

Correction: Yes, there is a bug here... There was an #include <p16f628> in one of the source code files... Sorry :)

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...