Writing Word and Integer Varibales direkt into EEProm

Post your requests and ideas on the future development of mikroPascal PRO for AVR.
Post Reply
Author
Message
corado
Posts: 399
Joined: 28 Mar 2009 11:03

Writing Word and Integer Varibales direkt into EEProm

#1 Post by corado » 12 Oct 2009 09:27

Hello,
for many things, I need the Funktion, that I can write word Variables into the EEprom (to calibrate ADC and so on)

khuenguyen
Posts: 8
Joined: 08 Sep 2009 04:30

#2 Post by khuenguyen » 13 Oct 2009 05:46

Hi, Guy!
i'm a new member!
i have some code, and i hope that it can help you!
void main()
{
unsigned long eeAddr;
int *ptrint;]
int a;
a=123;
//write EEPROM
eeAddr = 0x7FFC20;
ptrint = &a;
Eeprom_Write(eeAddr, *ptrint);
while(NVMCONbits.WR) ;
//read EEPROM
eeAddr = 0x7FFC20;
ptrint = &a;
*ptrint = Eeprom_Read(eeAddr);
}
....
it's ok.
Good luck!

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

#3 Post by Dany » 13 Oct 2009 09:36

Perhaps this can be also of some help: http://users.edpnet.be/rosseel01/DRO/PI ... iable.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)

corado
Posts: 399
Joined: 28 Mar 2009 11:03

#4 Post by corado » 23 Nov 2009 19:45

@Dany
thanks, but do you have an example how I use it?

I will write the Number 1020 for example, and then read it...
I don't know what I have to do with this

The procedures/functions need following parameters:
- the address of the valiable
- the size of the valiable
- the first (lowest) address in Eeprom to write to or read from
thanks

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

#5 Post by Dany » 24 Nov 2009 09:36

corado wrote:@Dany
thanks, but do you have an example how I use it?

I will write the Number 1020 for example, and then read it...
I don't know what I have to do with this

The procedures/functions need following parameters:
- the address of the valiable
- the size of the valiable
- the first (lowest) address in Eeprom to write to or read from
thanks

Code: Select all

var MyVar: word;
EePromAddress: word;
...
MyVar := 1020;  // MyVar gets some value

// write action
EePromAddress := 4; // the "MyVar" content will reside in EeProm place 4 and 5 for example
EePromWriteVariable(@MyVar, sizeof(MyVar), EePromAddress);
...
// read back action
EePromAddress := 4;
EePromReadVariable(@MyVar, sizeof(MyVar), EePromAddress);
You can also use a literal value for EePromaddress:

Code: Select all

...
EePromWriteVariable(@MyVar, sizeof(MyVar), 4);
...
EePromWriteVariable(@MyVar, sizeof(MyVar), 4);
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)

corado
Posts: 399
Joined: 28 Mar 2009 11:03

#6 Post by corado » 24 Nov 2009 11:23

And how can I write something into EEprom with AVRStudio, also via ISP Programmer?
In AVRco Pascal will be generatet an .eep File , this I can flash with ISp into the Atmega

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

#7 Post by Dany » 24 Nov 2009 20:12

corado wrote:And how can I write something into EEprom with AVRStudio, also via ISP Programmer?
In AVRco Pascal will be generatet an .eep File , this I can flash with ISp into the Atmega
No, idea, I work with PIC's only for now.
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)

Post Reply

Return to “mikroPascal PRO for AVR Wish List”