kate.gomez
Newbie level 4
Hi,
Good afternoon! I am currently working on a project using RTC. I had to evaluate the current time i.e. hour-minute basis, before executing a code. The EEPROM_Read(0x22) is set to store the current hour, and the EEPROM_Read(0x21) is set to store the current minute. However, the program seems to look at the first condition only, and does not recognize the presence of '&&' to evaluate whether both conditions were satisfied. For example, current time is 10:15, it will display the correct PORTB display, but when current time is 10:45, it will still follow the previous display. With this, I have assumed that the second condition is not really seen by the program.
Here is the part of the code:
if ((EEPROM_Read(0x22)==10) && (0<=EEPROM_Read(0x21)<=29))
PORTB = 0x01;
else if((EEPROM_Read(0x22)==10) && (30<=EEPROM_Read(0x21)<=59))
PORTB = 0x03;
else if((EEPROM_Read(0x22)==11) && (0<=EEPROM_Read(0x21)<=29))
PORTB = 0x07;
else if((EEPROM_Read(0x22)==11) && (30<=EEPROM_Read(0x21)<=59))
PORTB = 0x0F;
Good afternoon! I am currently working on a project using RTC. I had to evaluate the current time i.e. hour-minute basis, before executing a code. The EEPROM_Read(0x22) is set to store the current hour, and the EEPROM_Read(0x21) is set to store the current minute. However, the program seems to look at the first condition only, and does not recognize the presence of '&&' to evaluate whether both conditions were satisfied. For example, current time is 10:15, it will display the correct PORTB display, but when current time is 10:45, it will still follow the previous display. With this, I have assumed that the second condition is not really seen by the program.
Here is the part of the code:
if ((EEPROM_Read(0x22)==10) && (0<=EEPROM_Read(0x21)<=29))
PORTB = 0x01;
else if((EEPROM_Read(0x22)==10) && (30<=EEPROM_Read(0x21)<=59))
PORTB = 0x03;
else if((EEPROM_Read(0x22)==11) && (0<=EEPROM_Read(0x21)<=29))
PORTB = 0x07;
else if((EEPROM_Read(0x22)==11) && (30<=EEPROM_Read(0x21)<=59))
PORTB = 0x0F;