0

How to check if the eeprom at a particular address is null/empty or not. I'm using the PIC18F45Q43 and using eeprom_read() function.

Rafay Shams
  • 13
  • 1
  • 5
  • 1
    If you store characters in EEPROM you can check it with `NULL`, it is ok. But if you store numeric values then you can't check it with `NULL`. `NULL` is generally used to check pointers and string endings. How you should check the data validity is really depends on what data type you deal with. But since `eeprom_read()` function will return you a raw octet / byte data, you need to distinguish the returned data depending on what type of data you read. It may be a string data or an integer or float hence you have to deal with data convertion if necessary. – Kozmotronik Aug 25 '22 at 07:59
  • 1
    Normally `eeprom_read()`returns `0xFF` for an unprogramed EEPROM address. – Mike Aug 25 '22 at 09:15
  • Do you really want to check for NULL? NULL is normally used for pointers and can be defined as anything that the vendor decides: not necessarily zero. NULL and zero are not interchangable. When you program the EEPROM, have you checked in the hex code that that address is actually not written to? – cup Aug 27 '22 at 10:53

0 Answers0