Jump to content
Sign in to follow this  
Andy

Bank switch for EECON1 register wrong?

Recommended Posts

I'm writing code for a PIC16F873 and I'm trying to write to the internal EEPROM. It seems that the address for the EECON1 register is handled wrong. The generated code in assembler looks as follows:

 

bsf STATUS, RP0

bcf STATUS, RP1

btfsc EECON1, WR

 

but EECON1 is at address 18Ch and therefore RP0 and RP1 should both be 1.

 

Question1: is it possible to change the library (where is it loaded from)?

 

Question2: I tried to go around that by writing a patch:

 

Name: "EECON1 reg bank"

Debug: off

 

Pattern:

00. bcf STATUS, RP1

01. btfsc EECON1, WR

 

Action:

change 01 "\tbsf STATUS, RP1"

 

It doesn't work. Is there any syntax wrong? Where can I get information about patch-writing?

 

Any help appreciated - thank you.

Share this post


Link to post
Share on other sites
Guest Andy

I made a typing error in the second question:

 

It should look like:

Pattern:

00. bcf STATUS, RP1

01. btfsc EECON1, WR

Action:

change 00 "\tbsf STATUS, RP1"

 

But it doesn't work anyway.

Share this post


Link to post
Share on other sites

I had this problem too. The easiest way around it is to add this to one of your header files:

 

char EEEDATA @ 0x10C;

char EEEADR @ 0x10D;

char EEEDATH @ 0x10E;

char EEEADRH @ 0x10F;

char EEECON1 @ 0x18C;

char EEECON2 @ 0x18D;

 

Now you can use these new definitions in your source code, ie. use EEECON1 instead of EECON1 and all the bank switching will work perfectly.

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