View previous topic :: View next topic |
Author |
Message |
misel0019
Joined: 04 Oct 2010 Posts: 53 Location: Dhaka
|
data is not a BYTE |
Posted: Fri Oct 29, 2010 11:31 pm |
|
|
Code: |
#include <16F876A.H>
#fuses HS, WDT, NOPROTECT, NOBROWNOUT, NOPUT, NOLVP , NOCPD , NODEBUG
#use delay(clock=8000000)
//#device adc=10
#include <Flex_LCD420_2.c>
//#include <ds1307.c>
//#include <2404_byme.c>
long j;
void WRITE_LONG_EXT_EEPROM(long int n, float data) {
int i;
for (i = 0; i < 4; i++)
write_eeprom(i + n, *((int8*)&data + i) ) ;
}
float READ_LONG_EXT_EEPROM(long int n) {
int i;
long data;
for (i = 0; i < 4; i++)
*((int8*)&data + i) = read_eeprom(i + n);
return(data);
}
void main()
{
//unsigned int i;
delay_ms(500);
lcd_init();
delay_ms(10);
WRITE_LONG_EXT_EEPROM(0,55.55);
while(1)
{
lcd_gotoXY(1,1);
printf(lcd_putc," %f", READ_LONG_EXT_EEPROM(0));
}
}
|
What's the result of that program.
i think it would be 55.55.
but it shows 24196.00
why?? |
|
|
misel0019
Joined: 04 Oct 2010 Posts: 53 Location: Dhaka
|
SOlved |
Posted: Sat Oct 30, 2010 12:33 am |
|
|
Hurrah i have solved the problem
i need to take data variable
is the error.
i need to declare
No the question if i wanna write word in eeprom what can i do??
any suggestion??? |
|
|
misel0019
Joined: 04 Oct 2010 Posts: 53 Location: Dhaka
|
another question |
Posted: Sat Oct 30, 2010 12:38 am |
|
|
if i wanna use value big like
Code: | WRITE_LONG_EEPROM(0,1000000999); |
what can i do?? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Sat Oct 30, 2010 3:03 am |
|
|
Read the manual......
'Common questions and answers'
'How do I write variables to EEPROM that are not a byte'.
Best Wishes |
|
|
misel0019
Joined: 04 Oct 2010 Posts: 53 Location: Dhaka
|
solved |
Posted: Sat Oct 30, 2010 3:06 am |
|
|
Hurrah I have also solved the problem.
Thanks for the support. |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Wed Nov 03, 2010 9:53 am |
|
|
Well, I liked this thread, a good example of self learning with just a little push.
Thats good. Hurrah !! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Wed Nov 03, 2010 9:59 am |
|
|
As opposed to another thread running at the moment!....
Does show how it is 'easy' to help some people....
Best Wishes |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Wed Nov 03, 2010 10:26 am |
|
|
Yes Hamlett! that is why I remarked it.
Hope that Darren will taken an action and deleting it, it is not the style nor the mode in this forum.
Regards. |
|
|
|