I am programming PIC16F876A microcontroller (8 bit). Compiler Mikroc from Mikroelektronika. I have unsigned int variable Clock, which is 16 bit long and i need to write it to eeprom. As i understand, i need to convert this variable to two 8 bit variables, then write them to eeprom.
I am thinking to convert it in following way:
ClockHigh=Clock/255
ClockLow=Clock%255
and then store ClockHigh and ClockLow to eeprom .
When i need to retrieve variable Clock from eeprom, i am planning to use:
Clock=ClockHigh*255+ClockLow
Also i heard, that there is way to do all these conversations with shift operators >> and <<. I need most efficient way.
I am thinking to convert it in following way:
ClockHigh=Clock/255
ClockLow=Clock%255
and then store ClockHigh and ClockLow to eeprom .
When i need to retrieve variable Clock from eeprom, i am planning to use:
Clock=ClockHigh*255+ClockLow
Also i heard, that there is way to do all these conversations with shift operators >> and <<. I need most efficient way.