PDA

View Full Version : Help with Comparison and Variable Types



DiablodeMorte
04-07-2007, 11:07 AM
'ello everybody,

I've having alittle difficulty getting my IF statement working

Here's my code:



Seconds VAR Byte
AlarmSecond VAR Byte

IF((AlarmSecond = Seconds)) THEN Alarm


The IF statement never returns true!


When ever I refrenced Seconds I usually do it w/ Seconds.HIGHNIB and Seconds.LOWNIB
When I had AlarmSecond defined as such:


AlarmSecond = $21

the comparison worked, but when I derive AlarmSecond from a serin command the comparison fails.
I usually derived Seconds from the following line:



SHIFTOUT DTA, Clk, LSBFIRST, [%1\1,BrstReg\5,%10\2]
SHIFTIN DTA, Clk, LSBPRE, [Seconds,Minutes,Hours,Date,Month,Day,Year]




Any help?
Is there a function I'm missing?

Zoot
04-07-2007, 12:31 PM
What are you SHIFTINing from? In other words, how is the data formatted from the device that you are reading? Most likely your error is because the data coming in is not in the same format as your AlarmSecond. You will probably need to convert one or the other so they match.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST

DiablodeMorte
04-07-2007, 11:09 PM
I'm shifting in from the DS1302 timekeeping chip, the shiftin part of my code comes directly from parallax's sample code for the DS1302.

How would i convert this data to the right type?

Zoot
04-08-2007, 02:12 AM
So when you set AlarmSecond to be $21 you mean for it to be "21" seconds, correct? BCD notation just like the DS1302? Seems like it should be OK, then. Are you reading the DS1302 at least once per second?

Can you post your complete program?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST