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 create eeprom in mikroC?

Status
Not open for further replies.

swethamenon

Member level 4
Member level 4
Joined
Sep 12, 2012
Messages
70
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Visit site
Activity points
1,745
how to store data in eeprom ..code for that..
ii want to read & write a value into eeprom.
after 24hrs the last value to the memory should be that s4th hrs value..all the other previous data to b removed from memory.
in the next day,the last value +the new days energy valuse should get added..
how to do this?
 

Internal eeprom? See eeprom read and erite functions in mikroC help file. How are you calculating time (24 hours)? Are you using RTC like DS1307? Software timer will not be accurate.
 
Last edited:

For interfacing external eeprom you need to write your own libraries.

No need to write own library, MikroC have I2C Library

MikroC I²C Library
https://www.mikroe.com/download/eng/documents/compilers/mikroc/pro/pic/help/i2c_library.htm

Original MikroE example:
Code:
void main(){
  ANSEL  = 0;                // Configure AN pins as digital I/O
  ANSELH = 0;
  PORTB = 0;
  TRISB = 0;                 // Configure PORTB as output

  I2C1_Init(100000);         // initialize I2C communication
  I2C1_Start();              // issue I2C start signal
  I2C1_Wr(0xA2);             // send byte via I2C  (device address + W)
  I2C1_Wr(2);                // send byte (address of EEPROM location)
  I2C1_Wr(0xAA);             // send data (data to be written)
  I2C1_Stop();               // issue I2C stop signal

  Delay_100ms();

  I2C1_Start();              // issue I2C start signal
  I2C1_Wr(0xA2);             // send byte via I2C  (device address + W)
  I2C1_Wr(2);                // send byte (data address)
  I2C1_Repeated_Start();     // issue I2C signal repeated start
  I2C1_Wr(0xA3);             // send byte (device address + R)
  PORTB = I2C1_Rd(0u);       // Read the data (NO acknowledge)
  I2C1_Stop();               // issue I2C stop signal
}


Additional, also you can use SPI EEPROMs.




how to store data in eeprom ..code for that..
ii want to read & write a value into eeprom.
after 24hrs the last value to the memory should be that s4th hrs value..all the other previous data to b removed from memory.
in the next day,the last value +the new days energy valuse should get added..
how to do this?

Its not problem but lots of information dont exist in your post.

What is "energy values" ? How you collect that data over ADC,...

How you measure time, like uC internal timer used as counter or with external RTC IC ?

What if your device is off half day and you turn on now ? (counter starts from 0 or RTC?)




Best regards,
Peter

;-)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top