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.

save value of timer in eeprom

Status
Not open for further replies.

edwardcullen

Junior Member level 3
Joined
Aug 25, 2010
Messages
30
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
mauritius
Activity points
1,466
hi all,

anyone can help me how to save value of timer in eeprom?
i mean do i have to use i2c module?

thanks
 

You certainly need some kind of memory to save anything but it doesn't have to be I2C. You will have to be more specific about the size of the data and the platform you are running on to get a more useful answer.
Brian.
 

okay

i have my gatedtimer1 which save 16-bit values.
i want to save ths value in eeprom which will be displayed later in lcd.
 

Here is a assembly code to write a value to EEPROM.
Regards,
Jerin. ;-)
 

Attachments

  • eeprom write.txt
    850 bytes · Views: 79
  • eeprom_read.txt
    249 bytes · Views: 74

well
i am using c- language ..

thanks anyway

---------- Post added at 11:00 ---------- Previous post was at 10:35 ----------

hi ,
i am confused.

how do i save my timer value in eeprom?

how do i display value of eeprom in lcd?

all this in c language.

all the help will be highly welcomed
 

If you are using 'C', there is almost certainly a library with your compiler that handles writing and reading EEPROM.
Basically, to save the timer value, treat the 16 bits as two 8-bit values as the EEPROM will only have 8-bit wide data storage. For example "SaveToEEProm(address, (TimerValue & 0xFF00) >> 8;" to save the upper 8 bits and "SaveToEEProm(address + 1, (TimerValue & 0x00FF));" to save to lower bits. Substitute the correct syntax and a suitable address where appropriate.

To read the value, do the opposite. "variableHi = ReadFromEEProm(address);", "variableLo = ReadFromEEProm(address + 1)" then the original timer value is (variableHi << 8 ) | variableLo;

To display it on an LCD, use the standard 'C' printf or sprintf functions to convert the value to a string then send each byte to the LCD.

Brian.
 
hello thanks for ur help Brian.

SaveToEEProm(address, (TimerValue & 0xFF00) >> 8;
this above command i have never seen in library. i have only seen EEPROM_Write(eeAddr,eedata)..

i am using dspic30f4013, can u please elaborate on these command.

thanks
 

You didn't say which processor before and you still haven't said which compiler so I couldn't be more specific about the instruction.
Pick two addresses in the EEPROM, it's entirely up to you where you store the timer data. For my example lets call them "TimerStoreHi" and "TimerStoreLo" for the high and low 8-bits of the 16-bit Timer value. The EEPROM will almost certainly be 8 bits wide so it needs to be treated as an upper and lower byte. I'll break the instructions down to single steps so I can add comments, I've called the number in your timer "TimerData":

EEPROM_Write(TimerStoreHi, (TimerData & 0xFF00) >> 8 ); // the '&' isolates the top 8 or 16 bits, the >> shifts them to the lower 8 bits. So bits 15:8 are now in 7:0. Write them to TimerStoreHi in the EEPROM.
EEPROM_Write(TimerStoreLo, (TimerData & 0x00FF); // this time isolate only the lower 8 bits, then write them to address TimerStoreLo in the EEPROM.

So where you started with a 16 bit value, it is now split with the top 8 bits saved in TimerStoreHi and the bottom 8 bits in TimerStoreLo.

To recover the original value, you will have a function in the library that does the reverse of writing to EEPROM, I'm going to guess it is called EEPROM_Read(). Almost certainly it returns an 8 bit unsigned char when called with the EEPROM address between the ( and ). So to combine the two values again, you have to read the original 8 top bits from TimerStoreHi and shift them from bits 7:0 to 15:8 again by shifting all the bits by 8 positions to the left. Next, the lower 8 bits have to be read from TimerStoreLo and these have to be combined with the high value in the lower 8 bit places. The logic OR function does this. So the code to read the value is:

TimerData = EEPROM_Read(TimerStoreHi) << 8 ); // read high bits and shift them 8 places to the left (same as multiplying by 256 but uses less code!)
TimerData |= EEPROM_Read(TimerStoreLo); // logic OR the lower 8 bits to make the original 16 bit value.

Does that make sense?

Brian.
 

yes it makes sense.

sorry, i am using dspic30f4013 and easy6 board.

---------- Post added at 08:47 ---------- Previous post was at 08:25 ----------

also my eeprom is 16-bit
my timer data too is 16-bit

---------- Post added at 08:49 ---------- Previous post was at 08:47 ----------

also to display my data from eeprom to lcd, do i need to do conversions?
 

HELLO,

my chip is dspic30f4013 and board easy6board.

when i do the foll. does my gated timer1 automatically activates on sending pulse and automatically stops on receiving pulse?

void Timer1Init()
org 0x1A
{
TGATE=1;
TCS=0;
TON=1;
}
 

Sorry for not replying, my wife suffered a serious injury yesterday morning and had to be rushed to hospital in a helicopter, it has disrupted my usual routine somewhat !!

I'm not really familiar with the 30f4013 so I'll leave the answer to experts. At first glance I would guess it would not work as you intend. There doesn't seem to be anything to distinguish a sending pulse from a receiving one.

Brian.
 

hey i am really sorry for your wife, take care of her my friend.

do not worry friend i am now using CN configuration pins, i hope all go well.

u just take care, i thank u for all your precious help which was really appreciated.
thanks
edward
 

If you did get the code of EEPROM data storage & reading in C can you just attach it with your reply?
Regards,
Jerin. :)
 

Which compiler are you using?
 

I want to know which compiler you are using, not which language...
 

Hello,
nice i am new in this forum

---------- Post added at 15:20 ---------- Previous post was at 15:20 ----------

i like this forum very much
 

hi,
sir can you please see this program and tell me if you think this wiil do my job??

timer1 automatically activates on sending pulse and automatically stops on receiving pulse?
Void Timer1Init()
org=0x1A
{
LATD=~PORTD;
IFSO=IFSO & 0XFFF7;
}
void main()
{
TRISD=0;
LATD=0XAAAA;
IPCO=IPCO | 0X0008;
T1CON=0X8030;
}
Void_CNInterrupts()
{
TRISA=1;
ADPCFG=1;
CNEN1=0X00FF;
CNPU1=0X00FF;
IFSObits.CNIF=0;
IPC3bits.CNIP=3;
IECObits.CNIE=1;
}
 

If you have mikro C pro you will have their examples in your
installation folder.

Failing that if you ask on their forum I'm sure someone will
point you at a location to get them from.

If the chip you are using has built in eeprom (sorry I'm not familiar)
look up the EEPROM_write() and EEPROM_read() functions. Both are very easy
to use.

Just remember to link in the EEPROM library.

jack
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top