Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top