How to store adc value to internal eeprom

Status
Not open for further replies.

polona1010

Member level 1
Joined
Apr 17, 2013
Messages
40
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,524
I use 18f45k22 with mikroc and i need to measure adc and store data in internal eeprom, can someone help me?
 

Try this, it is for a Pic18f4331 but should work.
Hi-Tech compiler. uint8_t is an unsigned char.
Code:
/*--- Read eeprom ---*/

uint8_t read_eeprom(uint8_t address)
  {
  volatile uint8_t data;

  EEADR = address;
  EECON1bits.EEPGD = 0;
  EECON1bits.CFGS = 0;
  EECON1bits.RD = 1;
  data = EEDATA;
  return data;
  }

/*--- Write eeprom ---*/

void write_eeprom(uint8_t address, uint8_t data)
  {
  EEADR = address;
  EEDATA = data; 
  EECON1bits.EEPGD = 0;
  EECON1bits.CFGS = 0;
  EECON1bits.WREN = 1;
  EECON2 = 0x55;
  EECON2 = 0xaa;
  EECON1bits.WR = 1;
   
  while(EECON1bits.WR){
    ;
    }
    
  EECON1bits.WREN = 0;
  }
 
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…