Hi people!
Does anyone have any idea how to save longword to internal mega32 eeprom?
Please, heelp!
writing a longword to eeprom
Re: writing a longword to eeprom
Hi,
Just break the longword into bytes and put each byte into consecutive locations in EEPROM.
Regards,
Filip.
Just break the longword into bytes and put each byte into consecutive locations in EEPROM.
Regards,
Filip.
Re: writing a longword to eeprom
That was my first response but I held off to see what other responses came but perhaps the chap dunno how to do the split
hudyboy1, if you need more help how to split the longword into bytes then please
ask
M
hudyboy1, if you need more help how to split the longword into bytes then please
ask
M
Re: writing a longword to eeprom
Check user manual of mikroBasic for AVR.Muphy wrote: but perhaps the chap dunno how to do the split
On chapter 3, section "Built-In Routines" ... page 95++
Check : Lo(), Hi(), Higher(), Highest() functions
and if you can read french language, I remember we already discussed this stuff on mikroBasic for PIC forum long time ago http://www.mikroe.com/forum/viewtopic.p ... int+eeprom
Regards
http://www.pocketmt.com
Re: writing a longword to eeprom
Hi, perhaps this can help: http://www.rosseeld.be/DRO/PIC/EepromVariable.mpas
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Re: writing a longword to eeprom
Hi guys!
Thanks for the effort, I was browsing a bit and found out two procedures (one for read, the other one for...you know what for ).
I had the idea with hi and lo,but I made an error when I tried to divide already divided (lo and hi) long word.
Tnx again! (and special thanks to Dany for writing and to Corallaro for posting:) )
Btw, here's the code:
Hi Guys
There is a conversion of beautful routine wrote by Dany for mikropascal
http://users.edpnet.be/rosseel01/DRO/PI ... iable.mpas
http://users.edpnet.be/rosseel01/DRO/PIC/index.htm
tested in mikrobasic 6 and mikrobasic PRO 2.50 to write/read word variable in EEprom of a 16f88 and it works perfectly...
Code: Select all
'------------------------------------------------------------------------------
'-------- Unit EepromVariable --- version: 2009-09-16 for Mikrobasic-----------
'------------------------------------------------------------------------------
'
'INTERFACE:
'procedure EEPromWriteVariable(Dat as ^byte, Number, EEpromAddress as byte)
'procedure EEPromReadVariable(Dat as ^byte, Number, EEpromAddress as byte)
'These procedures/functions do write and read the content
'of any type of variable to/from Eeprom.
'
' The procedures/functions need following parameters:
' - the address of the variable
' - the size of the variable (8–bit=1, 16-bit=2, 32-bit=4)
' - the first (lowest) address in Eeprom to write to or read from'
' Take care of the mapping of the variables in Eeprom so that they do not overlap!
'CALLING THE ROUTINES:
'EePromWriteVariable(@Variable, sizeof(Variable), EePromAddress)
'EePromReadVariable(@Variable, sizeof(Variable), EePromAddress)
'IMPLEMENTATION:
'sub procedure EePromWriteVariable(dim Dat as ^byte, dim Number, EEpromAddress as byte)
'dim I as byte
' for I = 0 to Number -1
' EEProm_Write(EEPromAddress, Dat^)' // write the "I"th byte
' Delay_ms(25)
' Inc(Dat)
' Inc(EEpromAddress)
' next I
'end sub
'sub procedure EePromReadVariable(dim Dat as ^byte, dim Number, EEpromAddress as byte)
' dim I as byte
' for I = 0 to Number -1
' Dat^ = EEProm_Read(EEPromAddress)' // read the "I"th byte
' Delay_ms(25)
' Inc(Dat)
' Inc(EEpromAddress)
' next I
'end sub
'EXAMPLE:
'dim CurrentValue as word
'dim StoredValue as word
'CurrentValue = 1023
'EePromWriteVariable(@CurrentValue, 2, 10)
'Delay_us(500)
'EePromReadVariable(@StoredValue, 2, 10)
'Delay_us(500)
'WordToStr(StoredValue, Text)
'Lcd_Out(1, 1, Text)
'So in LCD display you view "1023"
'-------------------------------------------------------------------------------
Giovanni
Edited by Administrator: Added code Tag!
Thanks for the effort, I was browsing a bit and found out two procedures (one for read, the other one for...you know what for ).
I had the idea with hi and lo,but I made an error when I tried to divide already divided (lo and hi) long word.
Tnx again! (and special thanks to Dany for writing and to Corallaro for posting:) )
Btw, here's the code:
Hi Guys
There is a conversion of beautful routine wrote by Dany for mikropascal
http://users.edpnet.be/rosseel01/DRO/PI ... iable.mpas
http://users.edpnet.be/rosseel01/DRO/PIC/index.htm
tested in mikrobasic 6 and mikrobasic PRO 2.50 to write/read word variable in EEprom of a 16f88 and it works perfectly...
Code: Select all
'------------------------------------------------------------------------------
'-------- Unit EepromVariable --- version: 2009-09-16 for Mikrobasic-----------
'------------------------------------------------------------------------------
'
'INTERFACE:
'procedure EEPromWriteVariable(Dat as ^byte, Number, EEpromAddress as byte)
'procedure EEPromReadVariable(Dat as ^byte, Number, EEpromAddress as byte)
'These procedures/functions do write and read the content
'of any type of variable to/from Eeprom.
'
' The procedures/functions need following parameters:
' - the address of the variable
' - the size of the variable (8–bit=1, 16-bit=2, 32-bit=4)
' - the first (lowest) address in Eeprom to write to or read from'
' Take care of the mapping of the variables in Eeprom so that they do not overlap!
'CALLING THE ROUTINES:
'EePromWriteVariable(@Variable, sizeof(Variable), EePromAddress)
'EePromReadVariable(@Variable, sizeof(Variable), EePromAddress)
'IMPLEMENTATION:
'sub procedure EePromWriteVariable(dim Dat as ^byte, dim Number, EEpromAddress as byte)
'dim I as byte
' for I = 0 to Number -1
' EEProm_Write(EEPromAddress, Dat^)' // write the "I"th byte
' Delay_ms(25)
' Inc(Dat)
' Inc(EEpromAddress)
' next I
'end sub
'sub procedure EePromReadVariable(dim Dat as ^byte, dim Number, EEpromAddress as byte)
' dim I as byte
' for I = 0 to Number -1
' Dat^ = EEProm_Read(EEPromAddress)' // read the "I"th byte
' Delay_ms(25)
' Inc(Dat)
' Inc(EEpromAddress)
' next I
'end sub
'EXAMPLE:
'dim CurrentValue as word
'dim StoredValue as word
'CurrentValue = 1023
'EePromWriteVariable(@CurrentValue, 2, 10)
'Delay_us(500)
'EePromReadVariable(@StoredValue, 2, 10)
'Delay_us(500)
'WordToStr(StoredValue, Text)
'Lcd_Out(1, 1, Text)
'So in LCD display you view "1023"
'-------------------------------------------------------------------------------
Giovanni
Edited by Administrator: Added code Tag!