CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

data is not a BYTE

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
misel0019



Joined: 04 Oct 2010
Posts: 53
Location: Dhaka

View user's profile Send private message Send e-mail

data is not a BYTE
PostPosted: Fri Oct 29, 2010 11:31 pm     Reply with quote

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?? Shocked Rolling Eyes Shocked
misel0019



Joined: 04 Oct 2010
Posts: 53
Location: Dhaka

View user's profile Send private message Send e-mail

SOlved
PostPosted: Sat Oct 30, 2010 12:33 am     Reply with quote

Hurrah i have solved the problem

i need to take data variable



Code:

long data;


is the error.

i need to declare
Code:
float data;


No the question if i wanna write word in eeprom what can i do??
any suggestion??? Idea
misel0019



Joined: 04 Oct 2010
Posts: 53
Location: Dhaka

View user's profile Send private message Send e-mail

another question
PostPosted: Sat Oct 30, 2010 12:38 am     Reply with quote

if i wanna use value big like
Code:
WRITE_LONG_EEPROM(0,1000000999);


what can i do??
Ttelmah



Joined: 11 Mar 2010
Posts: 19545

View user's profile Send private message

PostPosted: Sat Oct 30, 2010 3:03 am     Reply with quote

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

View user's profile Send private message Send e-mail

solved
PostPosted: Sat Oct 30, 2010 3:06 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Nov 03, 2010 9:53 am     Reply with quote

Well, I liked this thread, a good example of self learning with just a little push.
Thats good. Hurrah !! Very Happy
Ttelmah



Joined: 11 Mar 2010
Posts: 19545

View user's profile Send private message

PostPosted: Wed Nov 03, 2010 9:59 am     Reply with quote

As opposed to another thread running at the moment!.... Very Happy

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

View user's profile Send private message

PostPosted: Wed Nov 03, 2010 10:26 am     Reply with quote

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. Very Happy
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group