Jump to content

Recommended Posts

Is there an issue with programming the PIC18F2520 EEPROM using BoostC?

 

Please try this anyone using PIC18F2520 chips.

 

Thanks

 

TWSource

 

example code that I am trying to get working:

 

void WrIEEPROM(unsigned char d, unsigned char a)

{

eeadr = a;

eedata = d;

eecon1.7 = 0;//EECON1_EEPGD = 0;

eecon1.6 = 0;//EECON1_CFGS = 0;

eecon1.2 = 1;//EECON1_WREN = 1;

intcon.7 = 0; //INTCON_GIE = 0;

eecon2 = 0x55;

eecon2 = 0x0AA;

eecon1.1 = 1;//EECON1_WR = 1;

intcon.7 = 1;//INTCON_GIE = 1;

while (eecon1.1);

eecon1.2 = 0;//EECON1_WREN = 0;

}

 

 

/********************************************************************************

*****

** BYTE RdIEEPROM(BYTE a) **

********************************************************************************

*****

* Read a byte from address 'a' of the internal EEPROM *

********************************************************************************

*****/

unsigned char RdIEEPROM(unsigned char a)

{

eeadr = a;

eecon1.7 = 0;//EECON1_EEPGD = 0;

eecon1.6 = 0;//EECON1_CFGS = 0;

eecon1.0 = 1;//EECON1_RD = 1;

return eedata;

}

Link to post
Share on other sites
  • 3 weeks later...
  • 3 months later...
  • 4 months later...

Dude lol works well! thanks even tho old post and was missing:

void WrIEEPROM(unsigned char d, unsigned char a)
{
eeadr = a;
eedata = d;
eecon1.7 = 0;//EECON1_EEPGD = 0;
eecon1.6 = 0;//EECON1_CFGS = 0;
eecon1.2 = 1;//EECON1_WREN = 1;
intcon.7 = 0; //INTCON_GIE = 0;
eecon2 = 0x55;
eecon2 = 0x0AA;
eecon1.1 = 1;//EECON1_WR = 1;
intcon.7 = 1;//INTCON_GIE = 1;
while (eecon1.1);
eecon1.2 = 0;//EECON1_WREN = 0;
pir2.EEIF=0;  /////////////////////////////////////you need this dude
}

Link to post
Share on other sites
BoostC comes with libraries that do EEPROM read/write. These functions can be found in eeprom.h

 

Regards,

Pavel

 

Yet it says the below:

 

EEPROM data memory interface for PIC16F87X devices

 

I used the above code for a :

PIC18F1320 & PIC18F448

 

You are right. I missed this. Can we use your code as a base to add EEPROM read/write into BoostC system libraries for PIC18 targets? Will your code work on PIC18 targets other than PIC18F1320 & PIC18F448?

 

Regards,

Pavel

Link to post
Share on other sites
You are right. I missed this. Can we use your code as a base to add EEPROM read/write into BoostC system libraries for PIC18 targets? Will your code work on PIC18 targets other than PIC18F1320 & PIC18F448?

 

Regards,

Pavel

 

Sure you can but weather it works on other targets depends But should. Since data was obtained from "PICmicro™ Mid-Range MCU Family Reference Manual" should be relevant to most if not all mid range pics.

Link to post
Share on other sites
  • 11 months later...
You are right. I missed this. Can we use your code as a base to add EEPROM read/write into BoostC system libraries for PIC18 targets? Will your code work on PIC18 targets other than PIC18F1320 & PIC18F448?

 

Regards,

Pavel

 

Sure you can but weather it works on other targets depends But should. Since data was obtained from "PICmicro™ Mid-Range MCU Family Reference Manual" should be relevant to most if not all mid range pics.

 

 

I just tried this with 18F2550 and seems to work. Manual is still wrong, so is header file. Will not compile for me unless .lib file is in the project as per: http://forum.sourceboost.com/index.php?sho...art=#entry15071

 

Would be nice to fix up the docs, .h. I am using 6.95 ;)

Link to post
Share on other sites

I use a slight variant on that for my generic EEProm writes, which I often use for simple/quick debugging:

 

void WriteEEP(unsigned char address, unsigned char data){
eecon1=0b00000100; // Initial eecon1 state - enables write
while( test_bit(eecon1, WR) ){
}
eeadr=address;
eedata=data;
eecon2=0x55;
eecon2=0xaa;
set_bit(eecon1, WR);
eecon1=0; // disable write (does not affect WR)
}

 

Here, the checking to see if the write is complete is at the top of the code - so avoiding a wait for the write to complete if there is no need to.

 

Also, as interrupts are not used, the GIE flag does not have to be set/cleared. This may be inappropriate for other code in use anyway.

Link to post
Share on other sites
...

I just tried this with 18F2550 and seems to work. Manual is still wrong, so is header file. Will not compile for me unless .lib file is in the project as per: http://forum.sourceboost.com/index.php?sho...art=#entry15071

 

Would be nice to fix up the docs, .h. I am using 6.95 ;)

 

Sources, headers and documentation have been corrected. Both EEPROM and Flash libraries now fully support PIC16 and PIC18 targets. These changes will be available in the coming 6.96 release.

 

Regards,

Pavel

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