Hi Eur,

On 2013/07/10 15:55, Eur van Andel wrote:

I got your rtcc_hw lib running on a PIC18F67K22. Thanks for the work.

Some remarks:

Most device files don't have the RTC register pointer spelled out in bits:

var volatile bit*2 RTCCFG_RTCPTR at RTCCFG : 0

I had to add these:

var volatile bit RTCCFG_RTCPTR1 at RTCCFG : 1
var volatile bit RTCCFG_RTCPTR0 at RTCCFG : 0

All device files have the bit*2 RTCCFG_RTCPTR and most of the device files have also the enumerated bits 1 and 0.
Unfortunately you chose the 'wrong' PIC....
I'll make a note to correct this (I'll probably change the libary to use the bit*2 variable, but I might add the missing enumerated bit declarations to the device file as well, or even do both).


Furthermore, not all PICs have a T1CON_T1OSCEN, in mine that is called
T1CON_SOSCEN.

I'll add an alias T1OSCEN for SOSCEN in the device files.

I powered my rtcc from the internal clock, since I need the C0 and C1
pins. No, that doesn't make it very accurate (+ 10 min/day!), but it
doesn't need to be.
Having access to hours, minutes and seconds is worth it.

Your clock setting routine is massive, which might overwhelm a newbie.
You have a 12-key keyboard, and you have six numbers to change. May I
suggest using 6 pairs of keys to increase or decrease these six values
(hh:mm:ss dd-mm-yy)? With a repeat freq of 5 per second, you only need
to hold a key for 6 seconds max.

procedure keyboard() is
if getkey() == 1 then hours = hours + 1 end if
if getkey() == 4 then hours = hours - 1 end if

if getkey() == 2 then minutes= minutes+ 1end if
if getkey() == 5 then minutes= minutes - 1 end if

if getkey() == 3 then date = date + 1 end if
if getkey() == 6 then date = date - 1 end if

etc.

That might make it easier to set time and date, although the keys don't have 'up' and 'down' arrows... I'll think about it. Thanks for the suggestion.


I snatched your beautiful bcd2bin() from rtcc_hw and copied it to
math.jal as bcd2bin8(), and added a slow bin2bcd8() as well. I did find
a 9-word (!) assembler one online:
http://www.microchip.com/forums/fb.ashx?m=69632 but it is too obscure
and uses mulwf which the 14 bit cores don't have.

I've searched many sources for a fast/small/elegant algorithm! In this case the honour goes to Scott Dattalo. I didn't find a very nice one for bin2bcd, but yours comes close.

I'd love to pull hours, minutes and seconds as binary bytes directly
from the rtcc, but there is no function for that yet.

I decided to read and write always the whole clock contents in a (rather primitive) attempt to avoid wrong values due to rollover. The datasheet is not quite clear (to me) at this point, but it recommends to repeat reads until two sequential reads give the same value. I thought this would be overkill for most situations.

Anyway, reading/writing individual seconds, minutes and hours wouldn't be too difficult to add, but to me this compares (too) much to programming in Assembler.

Regards, Rob.

PS: I'm very busy with converting the generation of Jallib device files to MPLAB-X in stead of MPLAB. On the site of Micrchip you can find an announcement that MPLAB 8 is 'archived' end of June (presumably this year!). So it is time to switch to MPLAB-X, and your suggestions may take sume time to be implemented.


--
R. Hamerling, Netherlands --- http://www.robh.nl

--
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/jallib.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to