The contents of the time and calendar register in DS1302 ar in BCD format.
23sec are 0x23, and not 0x17...
Se datasheet 'Register Address/Definition' (Table 2, page 8 in my datasheet)
Svenn
>
> Hi folks,
> I have a student using Codevision to pull the date and time from a
> DS1302 RTC and display it on an LCD, as well as use the data as
> integer values to calculate sunrise and sunset.
>
> Now, I'm not much of a C programmer, and the results we're getting
> look a bit odd. Now, the code is at work and I'm not, but what we're
> trying is:
>
> char hrs[3];
> char mins[3];
> char sec[3];
> int second;
>
> //Timer1 interrupt every second
> {
> //This was one way:
> rtc_get_time(hrs,mins,sec);
> lcd_gotoxy(0,0);
> lcd_puts(sec);
> }
>
> We also tried reading the bytes individually with
> second=DS1302_read(0xNN); //Can't remember address
> second=bin2hex(second);
> //Convert to string and dislpay
> itoa(second,sec);
> lcd_gotoxy(0,0);
> lcd_puts(sec);
>
> Now, we get odd values for everything - could someone please tell me
> (an assembler man) where we're going wrong?
>
>
> Thanks!
>
>
>
>
> Richard
> ---
> "Iz dana u dan ona dolazi i odlazi u talasima"
> http://www.van-gogh.co.yu/
>
>
>
> Yahoo! Groups Links
>
>
>
>Message
Re: [AVR-Chat] DS1302 / LCD / Codevision
2005-03-03 by Svenn Dahlstrøm
Attachments
- No local attachments were found for this message.