> In article <1157057976.567050.172630@b28g2000cwb.googlegroups.com>,
> "linnix" <me@linnix.info-for.us> wrote:
>
> > Al wrote:
> > > In article <3_DJg.9177$4O4.6831@trnddc02>,
> > > "Donald Harris" <harrisdw1@verizon.net> wrote:
> > >
> > > <big snip>
> > >
> > >
> > > > >
> > > > >>
> > > > >> I'm not attempting to do RTC inside the PIC as I want to use the
> > > > >> cheapest one available, like the 12C508A. And why reinvent the wheel.
> > > > >
> > > > > There are plenty of software library to implement a clock in PIC, which
> > > > > would cut the cost (and the RTC chip). You don't have to reinvent it.
> > > > >
> > > > >>
> > > > >> Al
> > > > >
> > >
> > > OK, I'll look for a library. Will it fit in the half K program section
> > > of the 12C508A as well as the other functionality I need? More analysis
> > > to do.
> > >
> >
> > Here is the core function, should compile to less than couple hundred
> > bytes:
> >
> > gSECOND++; // increment second
> >
> > if (gSECOND == 60)
> > {
> > gSECOND = 0;
> > gMINUTE++;
> >
> > if (gMINUTE > 59)
> > {
> > gMINUTE = 0;
> > gHOUR++;
> >
> > if (gHOUR > 23)
> > {
> > gHOUR = 0;
> > gDAY++;
> >
> > // Check for leap year if month == February
> > if (gMONTH == 2)
> > if (!(gYEAR & 0x0003)) // if (gYEAR%4
> > == 0)
> > if (gYEAR%100 == 0)
> > if (gYEAR%400 == 0)
> > LeapMonth = 1;
> > else
> > LeapMonth = 0;
> > else
> > LeapMonth = 1;
> > else
> > LeapMonth = 0;
> > else
> > LeapMonth = 0;
> >
> > // Now, we can check for month length
> > if (gDAY > (MonthLength[gMONTH] + LeapMonth))
> > {
> > gDAY = 1;
> > gMONTH++;
> >
> > if (gMONTH > 12)
> > {
> > gMONTH = 1;
> > gYEAR++;
> > }
> > }
> > }
> > }
> >
> > > Al
> >
>
> OK, looks good. I'll compile just this segment and see how much space it
> takes. I'll post the results here.
>
> Thanks for the tip.
>
> Now since I will be using the internal RC clock of the the 12C508A, how
> significantly will this impact the accuracy of the clock? I know that
> temperature effects will be important. If the code above works out with
> the space I have and the other functionality, I can use an exteranl XTAL
> for timing rather than use the two pins for connection to an external
> RTC. If I can eliminate the XTAL, that would be even better.
Use a watch crystal, it can't be more than 50 cents. Another way is to
track the power line frequency (50 or 60 hz) and adjust your internal
RC.
>
> BTW, this is a pro bono job for an application in the third world, so
> thanks again. It makes it a little easier for me. I am trying to keep
> the cost down to less than $5US/unit. I can't divulge the project, but
> you can guess that time in involved.
What else do you need? RTC and RS232 only?
>
> Al
Reply by Al●September 1, 20062006-09-01
In article <no.spam-A6551E.09275101092006@news.verizon.net>,
Al <no.spam@wanted.com> wrote:
> In article <1157057976.567050.172630@b28g2000cwb.googlegroups.com>,
> "linnix" <me@linnix.info-for.us> wrote:
>
<big snip>
>
> OK, looks good. I'll compile just this segment and see how much space it
> takes. I'll post the results here.
>
Here is the result for the RTC code you provided. It may just work out.
ROM used: 159 (31%)
159 (31%) including unused fragments
1 Average locations per line
5 Average locations per statement
RAM used: 14 (56%) at main() level
17 (68%) worst case
Lines Stmts % Files
----- ----- --- -----
69 31 100 C:\My Documents\Projects\Test\RTC.c
93 0 0 C:\Program Files\PICC\devices\12C508A.h
----- -----
324 62 Total
Page ROM % RAM Functions:
---- --- --- --- ----------
0 100 63 9 main
0 21 13 3 @DIV88
0 38 24 5 @DIV1616
Segment Used Free
--------- ---- ----
00000-001FF 159 349
Al
Reply by Al●September 1, 20062006-09-01
In article <1157057976.567050.172630@b28g2000cwb.googlegroups.com>,
"linnix" <me@linnix.info-for.us> wrote:
> Al wrote:
> > In article <3_DJg.9177$4O4.6831@trnddc02>,
> > "Donald Harris" <harrisdw1@verizon.net> wrote:
> >
> > <big snip>
> >
> >
> > > >
> > > >>
> > > >> I'm not attempting to do RTC inside the PIC as I want to use the
> > > >> cheapest one available, like the 12C508A. And why reinvent the wheel.
> > > >
> > > > There are plenty of software library to implement a clock in PIC, which
> > > > would cut the cost (and the RTC chip). You don't have to reinvent it.
> > > >
> > > >>
> > > >> Al
> > > >
> >
> > OK, I'll look for a library. Will it fit in the half K program section
> > of the 12C508A as well as the other functionality I need? More analysis
> > to do.
> >
>
> Here is the core function, should compile to less than couple hundred
> bytes:
>
> gSECOND++; // increment second
>
> if (gSECOND == 60)
> {
> gSECOND = 0;
> gMINUTE++;
>
> if (gMINUTE > 59)
> {
> gMINUTE = 0;
> gHOUR++;
>
> if (gHOUR > 23)
> {
> gHOUR = 0;
> gDAY++;
>
> // Check for leap year if month == February
> if (gMONTH == 2)
> if (!(gYEAR & 0x0003)) // if (gYEAR%4
> == 0)
> if (gYEAR%100 == 0)
> if (gYEAR%400 == 0)
> LeapMonth = 1;
> else
> LeapMonth = 0;
> else
> LeapMonth = 1;
> else
> LeapMonth = 0;
> else
> LeapMonth = 0;
>
> // Now, we can check for month length
> if (gDAY > (MonthLength[gMONTH] + LeapMonth))
> {
> gDAY = 1;
> gMONTH++;
>
> if (gMONTH > 12)
> {
> gMONTH = 1;
> gYEAR++;
> }
> }
> }
> }
>
> > Al
>
OK, looks good. I'll compile just this segment and see how much space it
takes. I'll post the results here.
Thanks for the tip.
Now since I will be using the internal RC clock of the the 12C508A, how
significantly will this impact the accuracy of the clock? I know that
temperature effects will be important. If the code above works out with
the space I have and the other functionality, I can use an exteranl XTAL
for timing rather than use the two pins for connection to an external
RTC. If I can eliminate the XTAL, that would be even better.
BTW, this is a pro bono job for an application in the third world, so
thanks again. It makes it a little easier for me. I am trying to keep
the cost down to less than $5US/unit. I can't divulge the project, but
you can guess that time in involved.
Al
Reply by linnix●August 31, 20062006-08-31
Al wrote:
> In article <3_DJg.9177$4O4.6831@trnddc02>,
> "Donald Harris" <harrisdw1@verizon.net> wrote:
>
> <big snip>
>
>
> > >
> > >>
> > >> I'm not attempting to do RTC inside the PIC as I want to use the
> > >> cheapest one available, like the 12C508A. And why reinvent the wheel.
> > >
> > > There are plenty of software library to implement a clock in PIC, which
> > > would cut the cost (and the RTC chip). You don't have to reinvent it.
> > >
> > >>
> > >> Al
> > >
>
> OK, I'll look for a library. Will it fit in the half K program section
> of the 12C508A as well as the other functionality I need? More analysis
> to do.
>
Here is the core function, should compile to less than couple hundred
bytes:
gSECOND++; // increment second
if (gSECOND == 60)
{
gSECOND = 0;
gMINUTE++;
if (gMINUTE > 59)
{
gMINUTE = 0;
gHOUR++;
if (gHOUR > 23)
{
gHOUR = 0;
gDAY++;
// Check for leap year if month == February
if (gMONTH == 2)
if (!(gYEAR & 0x0003)) // if (gYEAR%4
== 0)
if (gYEAR%100 == 0)
if (gYEAR%400 == 0)
LeapMonth = 1;
else
LeapMonth = 0;
else
LeapMonth = 1;
else
LeapMonth = 0;
else
LeapMonth = 0;
// Now, we can check for month length
if (gDAY > (MonthLength[gMONTH] + LeapMonth))
{
gDAY = 1;
gMONTH++;
if (gMONTH > 12)
{
gMONTH = 1;
gYEAR++;
}
}
}
}
> Al
Reply by Al●August 31, 20062006-08-31
In article <3_DJg.9177$4O4.6831@trnddc02>,
"Donald Harris" <harrisdw1@verizon.net> wrote:
<big snip>
> >
> >>
> >> I'm not attempting to do RTC inside the PIC as I want to use the
> >> cheapest one available, like the 12C508A. And why reinvent the wheel.
> >
> > There are plenty of software library to implement a clock in PIC, which
> > would cut the cost (and the RTC chip). You don't have to reinvent it.
> >
> >>
> >> Al
> >
OK, I'll look for a library. Will it fit in the half K program section
of the 12C508A as well as the other functionality I need? More analysis
to do.
Al
Reply by CBFalconer●August 31, 20062006-08-31
linnix wrote:
> Donald Harris wrote:
>
... snip ...
>>
>> The CE input is CHIP ENABLE, NOT Direction!
>
> Oh, yes. I read the wrong table. It should be Ok to pull it high.
> "linnix" <me@linnix.info-for.us> wrote in message
> news:1157036811.432184.292510@b28g2000cwb.googlegroups.com...
> >
> > Al wrote:
> >> In article <1156979843.522090.281930@h48g2000cwc.googlegroups.com>,
> >> "linnix" <me@linnix.info-for.us> wrote:
> >>
> >> > Al wrote:
> >> > > In article <1156882054.604376.170200@m79g2000cwm.googlegroups.com>,
> >> > > "linnix" <me@linnix.info-for.us> wrote:
> >> > >
> >> > > > > > Is this an appropriate newsgroup to submit questions regarding
> >> > > > > > PICs?
> >> > > > > >
> >> > > > > > I haven't been able to find any newsgroups listed as such that
> >> > > > > > are
> >> > > > > > provided by my ISP.
> >> > > > > >
> >> > > > > > Al
> >> > > > >
> >> > > > > Definitely. This is the place.
> >> > > >
> >> > > > Only if you are willing to ask the same question in an auditorium
> >> > > > full
> >> > > > of 500 experienced engineers.
> >> > > >
> >> > >
> >> > > OK, thanks. I'm overwhelmed by the response.
> >> > >
> >> > > First question.
> >> > >
> >> > > I want to use a real time clock for my application. I want to make
> >> > > the
> >> > > thing as cheaply as possible so I am looking for the lowlyest (??)
> >> > > PIC I
> >> > > can use. I have my sights set on the 12C508A.
> >> > >
> >> > > What I want to do is use two pins for the RT clock, two for
> >> > > controlling
> >> > > an external device, and two for communicating with the PIC from an
> >> > > external terminal service, yet to be determined.
> >> > >
> >> > > I know I may not have enough program space to do this, but I'm just
> >> > > starting.
> >> > >
> >> > > At any rate, what I want to know is this. A real time clock chip like
> >> > > the NJU6355 has three pins, CE, a clock and a data I/O. Can I do a
> >> > > hardware CE and still have full functionality of the RT clock using
> >> > > just
> >> > > the clock and I/O pins?
> >> >
> >> > What would your hardware CE be? It must determine the I/O direction
> >> > for the PIC to handle it properly. By the way, why can't you implement
> >> > the RTC inside the PIC?
> >> >
> >> > >
> >> > > As you can see, I run out of PIC pins if I can't.
> >> > >
> >> > > Al
> >> >
> >>
> >> According to the spec for the RTC, CE HIGH means that I/O is available
> >> and nothing else. So, as I think about it more, I think that I can just
> >> set it HIGH and as long as I am not querying the RTC, I should be
> >> getting nothing out. And if I ask for the day of the week, I should get
> >> that data out.
> >
> > I could be wrong, but CE determine the direction of the DATA pin.
> > Forgive me if I read the spec incorrectly.
> >
> >>
> >> I'm not attempting to do RTC inside the PIC as I want to use the
> >> cheapest one available, like the 12C508A. And why reinvent the wheel.
> >
> > There are plenty of software library to implement a clock in PIC, which
> > would cut the cost (and the RTC chip). You don't have to reinvent it.
> >
> >>
> >> Al
> >
>
> The CE input is CHIP ENABLE, NOT Direction!
Oh, yes. I read the wrong table. It should be Ok to pull it high.
>
> Don
Reply by Donald Harris●August 31, 20062006-08-31
"linnix" <me@linnix.info-for.us> wrote in message
news:1157036811.432184.292510@b28g2000cwb.googlegroups.com...
>
> Al wrote:
>> In article <1156979843.522090.281930@h48g2000cwc.googlegroups.com>,
>> "linnix" <me@linnix.info-for.us> wrote:
>>
>> > Al wrote:
>> > > In article <1156882054.604376.170200@m79g2000cwm.googlegroups.com>,
>> > > "linnix" <me@linnix.info-for.us> wrote:
>> > >
>> > > > > > Is this an appropriate newsgroup to submit questions regarding
>> > > > > > PICs?
>> > > > > >
>> > > > > > I haven't been able to find any newsgroups listed as such that
>> > > > > > are
>> > > > > > provided by my ISP.
>> > > > > >
>> > > > > > Al
>> > > > >
>> > > > > Definitely. This is the place.
>> > > >
>> > > > Only if you are willing to ask the same question in an auditorium
>> > > > full
>> > > > of 500 experienced engineers.
>> > > >
>> > >
>> > > OK, thanks. I'm overwhelmed by the response.
>> > >
>> > > First question.
>> > >
>> > > I want to use a real time clock for my application. I want to make
>> > > the
>> > > thing as cheaply as possible so I am looking for the lowlyest (??)
>> > > PIC I
>> > > can use. I have my sights set on the 12C508A.
>> > >
>> > > What I want to do is use two pins for the RT clock, two for
>> > > controlling
>> > > an external device, and two for communicating with the PIC from an
>> > > external terminal service, yet to be determined.
>> > >
>> > > I know I may not have enough program space to do this, but I'm just
>> > > starting.
>> > >
>> > > At any rate, what I want to know is this. A real time clock chip like
>> > > the NJU6355 has three pins, CE, a clock and a data I/O. Can I do a
>> > > hardware CE and still have full functionality of the RT clock using
>> > > just
>> > > the clock and I/O pins?
>> >
>> > What would your hardware CE be? It must determine the I/O direction
>> > for the PIC to handle it properly. By the way, why can't you implement
>> > the RTC inside the PIC?
>> >
>> > >
>> > > As you can see, I run out of PIC pins if I can't.
>> > >
>> > > Al
>> >
>>
>> According to the spec for the RTC, CE HIGH means that I/O is available
>> and nothing else. So, as I think about it more, I think that I can just
>> set it HIGH and as long as I am not querying the RTC, I should be
>> getting nothing out. And if I ask for the day of the week, I should get
>> that data out.
>
> I could be wrong, but CE determine the direction of the DATA pin.
> Forgive me if I read the spec incorrectly.
>
>>
>> I'm not attempting to do RTC inside the PIC as I want to use the
>> cheapest one available, like the 12C508A. And why reinvent the wheel.
>
> There are plenty of software library to implement a clock in PIC, which
> would cut the cost (and the RTC chip). You don't have to reinvent it.
>
>>
>> Al
>
The CE input is CHIP ENABLE, NOT Direction!
Don
Reply by linnix●August 31, 20062006-08-31
Al wrote:
> In article <1156979843.522090.281930@h48g2000cwc.googlegroups.com>,
> "linnix" <me@linnix.info-for.us> wrote:
>
> > Al wrote:
> > > In article <1156882054.604376.170200@m79g2000cwm.googlegroups.com>,
> > > "linnix" <me@linnix.info-for.us> wrote:
> > >
> > > > > > Is this an appropriate newsgroup to submit questions regarding PICs?
> > > > > >
> > > > > > I haven't been able to find any newsgroups listed as such that are
> > > > > > provided by my ISP.
> > > > > >
> > > > > > Al
> > > > >
> > > > > Definitely. This is the place.
> > > >
> > > > Only if you are willing to ask the same question in an auditorium full
> > > > of 500 experienced engineers.
> > > >
> > >
> > > OK, thanks. I'm overwhelmed by the response.
> > >
> > > First question.
> > >
> > > I want to use a real time clock for my application. I want to make the
> > > thing as cheaply as possible so I am looking for the lowlyest (??) PIC I
> > > can use. I have my sights set on the 12C508A.
> > >
> > > What I want to do is use two pins for the RT clock, two for controlling
> > > an external device, and two for communicating with the PIC from an
> > > external terminal service, yet to be determined.
> > >
> > > I know I may not have enough program space to do this, but I'm just
> > > starting.
> > >
> > > At any rate, what I want to know is this. A real time clock chip like
> > > the NJU6355 has three pins, CE, a clock and a data I/O. Can I do a
> > > hardware CE and still have full functionality of the RT clock using just
> > > the clock and I/O pins?
> >
> > What would your hardware CE be? It must determine the I/O direction
> > for the PIC to handle it properly. By the way, why can't you implement
> > the RTC inside the PIC?
> >
> > >
> > > As you can see, I run out of PIC pins if I can't.
> > >
> > > Al
> >
>
> According to the spec for the RTC, CE HIGH means that I/O is available
> and nothing else. So, as I think about it more, I think that I can just
> set it HIGH and as long as I am not querying the RTC, I should be
> getting nothing out. And if I ask for the day of the week, I should get
> that data out.
I could be wrong, but CE determine the direction of the DATA pin.
Forgive me if I read the spec incorrectly.
>
> I'm not attempting to do RTC inside the PIC as I want to use the
> cheapest one available, like the 12C508A. And why reinvent the wheel.
There are plenty of software library to implement a clock in PIC, which
would cut the cost (and the RTC chip). You don't have to reinvent it.
>
> Al
Reply by Al●August 31, 20062006-08-31
In article <1156979843.522090.281930@h48g2000cwc.googlegroups.com>,
"linnix" <me@linnix.info-for.us> wrote:
> Al wrote:
> > In article <1156882054.604376.170200@m79g2000cwm.googlegroups.com>,
> > "linnix" <me@linnix.info-for.us> wrote:
> >
> > > > > Is this an appropriate newsgroup to submit questions regarding PICs?
> > > > >
> > > > > I haven't been able to find any newsgroups listed as such that are
> > > > > provided by my ISP.
> > > > >
> > > > > Al
> > > >
> > > > Definitely. This is the place.
> > >
> > > Only if you are willing to ask the same question in an auditorium full
> > > of 500 experienced engineers.
> > >
> >
> > OK, thanks. I'm overwhelmed by the response.
> >
> > First question.
> >
> > I want to use a real time clock for my application. I want to make the
> > thing as cheaply as possible so I am looking for the lowlyest (??) PIC I
> > can use. I have my sights set on the 12C508A.
> >
> > What I want to do is use two pins for the RT clock, two for controlling
> > an external device, and two for communicating with the PIC from an
> > external terminal service, yet to be determined.
> >
> > I know I may not have enough program space to do this, but I'm just
> > starting.
> >
> > At any rate, what I want to know is this. A real time clock chip like
> > the NJU6355 has three pins, CE, a clock and a data I/O. Can I do a
> > hardware CE and still have full functionality of the RT clock using just
> > the clock and I/O pins?
>
> What would your hardware CE be? It must determine the I/O direction
> for the PIC to handle it properly. By the way, why can't you implement
> the RTC inside the PIC?
>
> >
> > As you can see, I run out of PIC pins if I can't.
> >
> > Al
>
According to the spec for the RTC, CE HIGH means that I/O is available
and nothing else. So, as I think about it more, I think that I can just
set it HIGH and as long as I am not querying the RTC, I should be
getting nothing out. And if I ask for the day of the week, I should get
that data out.
I'm not attempting to do RTC inside the PIC as I want to use the
cheapest one available, like the 12C508A. And why reinvent the wheel.
Al