I am writing data to eeprom AT24C16 using PIC microcontroller pic18f4520. Every address of this eeprom can hold 8-bits while I am using long int's to store data that are 16-bit in size. How to break long int into 2 8-bit parts to write them and how to get them back together after reading from eeprom??
Electronic – Breaking a 16-bit long int to write into eeprom
atmeldataeeprommicrocontrollerpic
Related Topic
- How to effectively tackle long page write in EEPROM
- Electronic – Will an SPI flash memory chip have the same issues with non-atomic write operations as a dsPIC’s internal EEPROM
- Writing 3 bytes data in EEPROM
- Electronic – PIC EEPROM after re-programming
- Electrical – Atmel SPI Serial EEPROM Writing Error – Page Write
- Electronic – EEPROM Interface confusion with Address
Best Answer
In C, you can use bit-shift and masking to extract each byte of a longer number:
And you can 'reassemble' the number from bytes by doing the reverse: