hi,
i need to convert by u_16 bit value which is between 200-2000 mS into u_8 in order to store it in my 8-bit eeprom.
((u_8)val&0xff)|((u_8)val&0xff)>>8;
this is the formula that i am using but if the val = 2000 i am getting an output of 208 where, 0x07D0 (D0 = 208) similarly if i am changing val to 300 the output becomes 44 which is 0x012c (2c = 44). why is that so and how do i rectify it, is my formula correct????
i have tried several methods to do so such as:
//storing
note: i can write the values but when i read it, it resets to some diff value such as 300 = 44, however, as long as the value is between 0-255 (8-bit val) i can read exact same values. is it issue with the pointer or formula, the rest the code works perfectly fine i just have issues with saving my 16bit val onto an 8-bit eeprom.
it is from low to high 200-2000, where 200 is the default val
As long as I am typing again, start using some spaces in your exprsssions. The compiler doesn't care butitisveryhsrdtoreadstuffwithoutslaces. Or see typos.