Yahoo Groups archive

AVR-Chat

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

Message

DS1302 / LCD / Codevision

2005-03-03 by Richard Reeves

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/

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.