View previous topic :: View next topic |
Author |
Message |
ritchie
Joined: 13 Sep 2003 Posts: 87
|
Need help on int32 number storage to external memory |
Posted: Wed Dec 17, 2003 8:24 pm |
|
|
Hello,
Anybody in the forum/community who can provide me any help on how to store an unsigned int32 variable to an external memory using I2C (e.g. FM24C256)?
A sample code snippet would help?
Thanx |
|
|
fpgeh
Joined: 07 Sep 2003 Posts: 19 Location: Vancouver, BC
|
|
Posted: Wed Dec 17, 2003 8:49 pm |
|
|
Assuming you have the CCS compilier, look in the "drivers" directory for the file "24256.c" and in the "examples" directory for "ex_extee.c".
To break the 32 bit value into bytes you can use the "make8" built-in function. |
|
|
ritchie
Joined: 13 Sep 2003 Posts: 87
|
|
Posted: Wed Dec 17, 2003 10:14 pm |
|
|
fpgeh wrote: | Assuming you have the CCS compilier, look in the "drivers" directory for the file "24256.c" and in the "examples" directory for "ex_extee.c".
To break the 32 bit value into bytes you can use the "make8" built-in function. |
Thank u for the info in using the built-in make8() function of the CCS compiler.
Would it be possible using also the page write method in storing int32 numbers to external memory? Any ideas on how to do this? maybe a sample snippet will help...
Thanx |
|
|
Guest
|
|
Posted: Thu Dec 18, 2003 1:28 am |
|
|
ritchie wrote: |
Thank u for the info in using the built-in make8() function of the CCS compiler.
Would it be possible using also the page write method in storing int32 numbers to external memory? Any ideas on how to do this? maybe a sample snippet will help...
Thanx |
I hope this would help......
Code: |
//************************************************************************
void write_fram_int32(
//unsigned int32 uAddress, // memory address to write data
unsigned int8 uAddress,
unsigned int32 uData) // put your data here
{
//unsigned int32 dummy;
unsigned int8 dummy;
for (dummy=0; dummy<4; dummy++)
write_fram_byte(dummy+uAddress,*(&uData+dummy));
}
//************************************************************************
unsigned int32 read_fram_int32(
//unsigned int32 uAddress) // specify memory address to read data
unsigned int8 uAddress)
{
//unsigned int32 dummy;
unsigned int8 dummy;
unsigned int32 uData;
for (dummy=0; dummy<4; dummy++)
*(&uData+dummy) = read_fram_byte(dummy+uAddress);
return(uData);
}
|
happy coding >>>>> |
|
|
|