[SOLVED] Error reading float and int values from EEPROM.

Status
Not open for further replies.

Raady Here

Full Member level 5
Joined
Jun 8, 2013
Messages
242
Helped
26
Reputation
52
Reaction score
26
Trophy points
28
Location
India
Visit site
Activity points
1,571
Hi,

I am unable to read the exact values from EEPROM,
I am getting negative values when read !

Please suggest me, if my syntax had gone wrong !
View attachment EEPROM.rar
Zipping the code in attachments

Code:
ptr = (unsigned char*)&Voltage_Low ; 
	Write_String_EEPROMx(2,ptr, EE_CUTOFF_LOW);
	
	ptr1= (unsigned char*)&Voltage_Low ; 
	Read_String_EEPROMx(2,(unsigned char*)&ptr1, EE_CUTOFF_LOW);			
	Voltage_Low1 = ConvertSTRING_Int(ptr1,2);

	printf("\n Voltage_Low: %d",Voltage_Low1);


	ptr = (unsigned char*)&MUL_R;
	Write_String_EEPROMx(4, ptr, EE_MULT_FACT_R);
	Read_String_EEPROMx(4, ptr, EE_MULT_FACT_R);
 

You are writing an reading an integer in binary format. Performing ConvertSTRING_Int() makes no sense.

Why do you think that the operations with float value goes wrong?
 
Sorry forgot mentioning details PIC30F5011, MPLAB8.8V

In the example I quoted I have written 200 (int value), but when reading int I am getting it as -360 and when convert to int it shows some block.
It similar when with float it shows 0.0000 what ever value is inserted !
 

Thanks FVM, I get what you said. I wrote in binary format and again making conversion !
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…