Jump to content
Sign in to follow this  
Allegro

Eepromwrite() And Eepromread() Functions

Recommended Posts

I write for PIC18 series...

 

/*******************************************************************************
Written & Developer   : Erol YILMAZ
Start ..............  : 23.April.2010
Update .............  : 25.April.2010
Operating System....  : SourceBoost Novo
Program Name .......  : ErOS_eeprom.h
Target MCU .........  : PIC18 Series
Compiler ...........  : SourceBoost C Compiler v6.96
PIC18F4423 için yazıldı.
PIC16 serisine de uyarlanabilir...

...You can use with...
#include "ErOS_eeprom.h"

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

typedef bit			  BOOLEAN;
typedef unsigned char	INT8U;
typedef signed   char	INT8S;
typedef unsigned int	 INT16U;
typedef signed   int	 INT16S;
typedef unsigned long	INT32U;
typedef signed   long	INT32S;


/*******************************************************************************
* E.r.O.S. eepromRead()
*******************************************************************************/
INT8U eepromRead(INT8U adres){

eeadr = adres;
eecon1.EEPGD = 0;
eecon1.CFGS = 0;
eecon1.RD = 1;

return(eedata);
}


/*******************************************************************************
* E.r.O.S. eepromWrite()
*******************************************************************************/
void eepromWrite(INT8U adres, INT8U sayi){
#define MAX_TRY	 5
INT8U   intconBackup;

for(INT8U i=0; i<MAX_TRY; i++){

	intconBackup = intcon;
	eeadr = adres;
	eedata = sayi;
	eecon1.EEPGD = 0;
	eecon1.CFGS = 0;
	eecon1.WREN = 1;
	intcon.GIE = 0;
	eecon2 = 0x55;
	eecon2 = 0xAA;
	eecon1.WR = 1;
	intcon = intconBackup;
	eecon1.WREN = 0;
	while(eecon1.WR)	clear_wdt();
	if(sayi == eepromRead(adres)) return;
}

//ERROR_STATE |= ERROR_INT_EEPROM;

return;
}

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