Shop OBEX P1 Docs P2 Docs Learn Events
What's wrong with my Timer? — Parallax Forums

What's wrong with my Timer?

jmspaggijmspaggi Posts: 629
edited 2008-05-12 19:02 in General Discussion
Hi there,

I have code a kind of clock using timeout(1000). It works pretty well, but now, I want to add the minutes, and would like to use timeout (high, low) instead of the one using the ms.

After looking at Timer code, I have define
ONESECONDHIGH = 1; // 1000 / 569
ONESECONDLOW = 0xC1<<8 + 0x9D; // (1000%569)*115 = 49565

But using timeout (ONESECONDHIGH, ONESECONDLOW) instead of timeout (1000) make my clock running way faster than the regular one.

I suspect my constants ONESECONDLOW and ONESECONDHIGH to be wrong, because if I modify ONESECONDHIGH with 2, instead of 1, then I'm slowler than the 1s delay, but I can't figure what's wrong.

Has anyone any hint for me? Is ONESECONDLOW wrong?

Thanks,

Jean-Marc

Comments

  • jmspaggijmspaggi Posts: 629
    edited 2008-05-12 19:02
    I reply to myself [noparse];)[/noparse]

    I think I found where the issue was. It's regarding 0xC1<<8 + 0x9D which is interpreted as something about 1700 instead of the expected 49000.

    So I removed 1, and revert the number, which gave me -15971, and I replaced my 0xC1<<8 + 0x9D by -15971, and look like it's now working fine.

    JM
Sign In or Register to comment.