IF condition problem
AGCB
Posts: 327
in Propeller 1
Is there a problem with this IF condition as I have it? I can't seem to make it work.
IF (timbuf[hours]==6) AND (timbuf[minutes]==59) AND (timbuf[seconds]=>40)
Comments
Mike
I base this on these lines, where you're handling the display of the values in hex:
This means that you need to convert the value from BCD to binary before any comparisons.
Walter
For this chip, the high bit has to be set for 12 hour mode (instead of 24 hour mode).
Which means that Aaron's code will need to also account for AM/PM when making the time comparison. Otherwise it will trigger twice a day.
wmosscrop
The RTC is a DS3231N and yes it is BCD output. I'll have to play with your conversion code. I also found this one in my old notes. . Don't know if they work similar.
I'm displaying 24 hour mode.
Dave Hein
That brings up a second minor problem in that when the hour should read 10 it actually reads 0A. I've done RTC displays before and not had this problem. Must have used a different code then but can't find it.
The timbuf is a global byte VAR (IE) BYTE timbuf[7].
The RTC updates once per second (RTC COG) and the main loop takes about 4 - 6 seconds.
Thanks
Aaron
In addition, bit 6 is used to denote PM status in 12 hour mode.
In other words, 10 PM in 12 hour mode would have the binary value %0101_0000.
Your code won't work, it needs to strip off the high 2 bits of the value:
Aaron
As usual, when I ask a question on this forum I learn more than I expected.
Aaron