Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] DS1302 / LCD / Codevision

2005-03-03 by Richard Reeves

Svenn:
> The contents of the time and calendar register in DS1302 ar in BCD format.
> 23sec are 0x23, and not 0x17...
Yes, sorry, I typed the wrong thing in my original email (the code is at
work and I was at home.)  We were using:

second=DS1302_read(0xNN); //Can't remember address
second=bcd2bin(second)
//Convert to string and dislpay
itoa(second,sec);
lcd_gotoxy(0,0);
lcd_puts(sec);

Now, if I convert it from BCD to binary and read it out, it should, in the
case of the seconds counter, get to 59 and roll over to 0, but doesn't. 
In fact, it doesn't give sensible numbersat all...

It's very confusing to say the least.  If I retrieve a BCD value, and use
bcd2bin (as we need an int for calculations), surely creating a string
from it to display should work.

Any help is much appreciated.


Richard
-- 
Na vratima raja, ja savijam krila...
http://www.van-gogh.co.yu

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.