Searching \ for '[PIC]: 877 and Dallas 1302' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=877
Search entire site for: '877 and Dallas 1302'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: 877 and Dallas 1302'
2002\06\05@083308 by John Brown

picon face
I am trying to hook a Dallas 1302 Timekeeping chip up to a 16f877. I am using PortD 4-6 for the 3-wire interface, and the read/write routines available from Dontronic's rtc1302.asm file (appropriately modified to work on the pins I have selected). Is there any problems with using these routines on a 877? Are there better ones?

My main problem is that I can't seem to get it going, which is always annoying! I was wondering if anyone has any ideas? I have confirmed that the chip is correctly wired to the correct pins :-) and as far as I can tell it is all wired up correctly.

I am using a RomZap III Bootloader and hardware kit. My code is listed below with all of the RomZap bits removed (I don't think I've left any important bits out):

       list P = 16F877
       list r=dec           ;radix decimal
;
       include "P16f877.inc"
;
; CRYSTAL SPEED = 4000000Hz
;
; ------------------
; CONFIGURATION FUSE
; ------------------
;
       __CONFIG _CP_OFF & _WRT_ENABLE_ON & _HS_OSC & _WDT_OFF & _PWRTE_OFF & _BODEN_OFF & _LVP_OFF & _CPD_OFF & _DEBUG_OFF


CBLOCK 0x20
       count1                  ;counts 1,2,3 are for gen purpose
       count2                  ;delay routines
       count3                  ;
       timer1                  ;for 8bit rotates in/out
       timer2                  ;per Mark Sullivan's code 25.7.96
       timer3                  ;for the ds1202 or ds1302
       count4                  ;real-time-clock
       second                  ;
       minute                  ;
       hour                    ;
       date                    ;
       month                   ;
       day                     ;
       year                    ;
ENDC

;DALLAS Date and Time Chip
clk             equ     6               ;rtc clock (=sclk)
dataq           equ     5               ;rtc dq data line (=I/O)
_rst            equ     4               ;rtc reset line         LO=res
#define         CLKRST  portd,_rst      ;RTC reset line LO=reset HI=active
#define         SCLK    portd,clk       ;RTC clock line
#define         CLKDATA portd,dataq     ;RTC I/O data line

UCode   bsf     STATUS,RP0      ; select register bank 1
       bcf     STATUS,RP1      ;
;
       bcf     TRISE, PSPMODE
;
       bcf     trisd,_rst
       bcf     trisd,clk
       bsf     trisd,dataq
;
       bcf     STATUS, RP0     ; select register bank 0
;
       movlw   0               ; date and time to be used when setting date and time
       movwf   second
       movlw   0
       movwf   minute
       movlw   10
       movwf   hour
       movlw   25
       movwf   date
       movlw   5
       movwf   month
       movlw   7
       movwf   day             ; the day of the week, where 1=Sun ... 7=Sat
       movlw   2
       movwf   year
;
       bcf     second,7        ;clear `clock halt' CH bit
       bcf     hour,7          ;24 hr mode
;
       call    wclock
;
loop    call    delay_10sec
       call    rclock
;
       BreakCode 0x01   ;OK I left one RomZap command in. I dont see any
                       ;changes I expect in the time registers at this point
;
       goto    loop
;
;---START--- Cut, Pasted an Modified from Dontronic's rtc1302.asm file
;
;
; Write calendar clock
; per Mark K Sullivan 25.7.96
;       this routine takes ALL the seconds ---> year fregs in 16f84 and
;       writes them to the ds1302. NB that means that if you want to adjust
;       the rtc time registers, you have to do a read first (of them all).
;       The rclock routine following, reads the whole lot in `burst mode'
;       and puts the values into seconds --->year fregs

wclock  bcf     SCLK            ;negate clock line
       nop
       nop
       nop
       nop
       bcf     CLKDATA
       bsf     CLKRST          ;negate RST
       bsf     status,rp0      ;I/O dataq line set to output
       bcf     trisd,dataq
       bcf     status,rp0
;
       BreakCode 0x02
;
       movlw   0x8E            ;write control register
       call    wbyte
       movlw   0x00            ;turn off Write Protect in rtc
       call    wbyte
       movlw   7
       movwf   timer3
       movlw   0x80            ;rtc register address for `second'
       movwf   count4
       movlw   second
       movwf   fsr
wc      bcf     CLKRST          ;assert RST
       bcf     SCLK            ;negate clock
       nop
       nop
       nop
       nop
       bsf     CLKRST          ;negate RST
       movf    count4,W
       call    wbyte
       movf    indf,W
       call    wbyte
       incf    fsr
       incf    count4
       incf    count4
       decfsz  timer3
       goto    wc
       bcf     CLKRST          ;assert RST
       return

;
; Read calendar clock
;


rclock  bcf     SCLK            ;negate clock
       nop
       nop
       nop
       nop
       bcf     CLKDATA         ;negate I/O
       bsf     CLKRST          ;negate RST
       bsf     status,rp0      ;I/O dataq line set to output
       bcf     trisd,dataq
       bcf     status,rp0
       movlw   0xBF            ;burst read clock registers
       call    wbyte
       bsf     status,rp0      ;I/O dataq line set to input
       bsf     trisa,dataq
       bcf     status,rp0
       movlw   second
       movwf   fsr
       call    rbyte
       call    rbyte
       call    rbyte
       call    rbyte
       call    rbyte
       call    rbyte
       call    rbyte
       bcf     CLKRST          ;assert RST
       return

wbyte   movwf   timer2
       movlw   8
       movwf   timer1
wbit    bcf     SCLK
       btfss   timer2, 0
       bcf     CLKDATA
       btfsc   timer2, 0
       bsf     CLKDATA
       nop
       nop                     ;data to clock setup
       nop
       bsf     SCLK
       rrf     timer2
       decfsz  timer1
       goto    wbit
       return

rbyte   movlw   8
       movwf   timer1
rbit    bcf     SCLK
       nop
       nop                     ;clock to data delay
       rrf     indf
       bcf     indf, 7
       btfsc   CLKDATA
       bsf     indf, 7
       bsf     SCLK
       nop
       nop
       decfsz  timer1
       goto    rbit
       incf    fsr
       return
;********************************************specific rtc ds1302 routines end
;
delay1          decfsz  count3, 1     ;2 + 5*(count3-1) +
               goto    $-1             ;2 + (5*255 +2+5) * (count2-1) +
               decfsz  count2, 1     ;2 + (5*255*256 +2 + 5*255 +2+5) *(count1-1)
               goto    $-3             ;  =
               decfsz  count1, 1     ;5(count3-1)+1282(count2-1)+327684(count1-1)+6           &nb
               goto    $-5             ;
               return                  ;
;
delay_1sec      movlw   0x04            ;1 second delay
               movwf   count1
               movlw   0x0E
               movwf   count2
               movlw   0x38
               movwf   count3
               call    delay1
               return
;
delay_10sec     movlw   0x1F            ;10 second delay
               movwf   count1
               movlw   0x85
               movwf   count2
               movlw   0x34
               movwf   count3
               call    delay1
               return
;
;---END--- Cut,  Pasted an Modified from Dontronic's rtc1302.asm file
;



_______________________________________________________________________
John Brown
PhD (Clinical Psychology) candidate
                                     Email:  spam_OUTjohn.brownTakeThisOuTspamanu.edu.au
School of Psychology                  Phone:  (02) 6125-3827
Room 124, Building 39, Psychology     Fax:    (02) 6125-0499
The Australian National University    Mobile: 0429 455 504
ACTON ACT 0200   Web: http://www.anu.edu.au/psychology/staff/BrownJ.htm

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam@spam@mitvma.mit.edu


2002\06\05@102306 by Paul Hutchinson

flavicon
face
I've not worked with that particular Dallas RTC chip but, I've found with
other models that if the backup battery is not connected the chip doesn't
work.

Paul

> {Original Message removed}

2002\06\05@183501 by John Brown

picon face
At 10:20 AM 5/06/2002 -0400, you wrote:
>I've not worked with that particular Dallas RTC chip but, I've found with
>other models that if the backup battery is not connected the chip doesn't
>work.

I have a super-capacitor hooked up, but it isn't charged. I might try
charging it and seeing if that sparks it into life.

Thanks.

John



>Paul
>
> > {Original Message removed}

2002\06\05@185357 by David Duffy

flavicon
face
part 1 1246 bytes content-type:text/plain; x-avg-checked=avg-ok-60731876; charset=us-ascii; format=flowed (unknown type 8bit not decoded)

John Brown wrote:
>I am trying to hook a Dallas 1302 Timekeeping chip up to a 16f877. I am
>using PortD 4-6 for the 3-wire interface, and the read/write routines
>available from Dontronic's rtc1302.asm file (appropriately modified to
>work on the pins I have selected). Is there any problems with using these
>routines on a 877? Are there better ones?
>
>My main problem is that I can't seem to get it going, which is always
>annoying! I was wondering if anyone has any ideas? I have confirmed that
>the chip is correctly wired to the correct pins :-) and as far as I can
>tell it is all wired up correctly.

If what way does it not work? Can you read & write the time?
Does the time tick over by itself?  I used the DS1307 a while
ago & you have to set the oscillator bit in one of the registers
to get it running. I don't know if the DS1302 is the same but it
may be worth looking at.
Regards...

___________________________________________
David Duffy        Audio Visual Devices P/L
U8, 9-11 Trade St, Cleveland 4163 Australia
Ph: +61 7 38210362   Fax: +61 7 38210281
New Web: http://www.audiovisualdevices.com.au
___________________________________________


part 2 105 bytes
--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamKILLspammitvma.mit.edu


2002\06\05@190050 by M. Adam Davis

flavicon
face
Use a diode to power the device battery input and charge the cap from
the regular supply.

A quick, simple (and common) fix.

-Adam

John Brown wrote:

{Quote hidden}

>> > {Original Message removed}

2002\06\05@190458 by John Brown

picon face
At 08:54 AM 6/06/2002 +1000, you wrote:
>John Brown wrote:
>>I am trying to hook a Dallas 1302 Timekeeping chip up to a 16f877. I am
>>using PortD 4-6 for the 3-wire interface, and the read/write routines
>>available from Dontronic's rtc1302.asm file (appropriately modified to
>>work on the pins I have selected). Is there any problems with using these
>>routines on a 877? Are there better ones?
>>
>>My main problem is that I can't seem to get it going, which is always
>>annoying! I was wondering if anyone has any ideas? I have confirmed that
>>the chip is correctly wired to the correct pins :-) and as far as I can
>>tell it is all wired up correctly.
>
>If what way does it not work? Can you read & write the time?

I attempt to write the time, wait 10 seconds and then read it back. But the
results of my attempt to read are all zeros. I have no idea if the attempt
to write to it is working, or if the time is ticking over. At this stage I
am assuming that I am not writing successfully to the chip and therefore it
isn't ticking.

My understanding is that all I have to do to start it tick is clear bit 7
of the second register (which I then write to the chip), but I assume this
message isn't getting through at the moment.

>         bcf     second,7        ;clear `clock halt' CH bit

Actually, I just remember that one thing I am not doing correctly is that
the numbers I write to the chip should be binary coded decimal, when in
fact at the moment my code is writing just plain decimal. This shouldn't
stop the communications though, I should just be setting to the wrong time
and date! Setting the wrong time and date would be better than nothing!

Thanks,

John


{Quote hidden}

_______________________________________________________________________
John Brown
PhD (Clinical Psychology) candidate
                                      Email:  .....john.brownKILLspamspam.....anu.edu.au
School of Psychology                  Phone:  (02) 6125-3827
Room 124, Building 39, Psychology     Fax:    (02) 6125-0499
The Australian National University    Mobile: 0429 455 504
ACTON ACT 0200   Web: http://www.anu.edu.au/psychology/staff/BrownJ.htm

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspam_OUTspamTakeThisOuTmitvma.mit.edu


2002\06\05@212448 by Chris Loiacono

flavicon
face
Two quick things that you may or may not have considered:

The 1302 has a maximum capacitance spec for the 32K clock crystal. Exceeding
this will prevent it from running. I've also had boards with the most minute
amount of flux & wash muck around the crystal and chip that wouldn't run.
Extra cleaning is called for.

Next, I haven't checked your code, but a common eror is to ignore the fact
that the 1302's SCLK must be low when /RST is brought high to start a
sequence.

Sorry I have used this chip a good number of times, but not with PICs. This
is all I can offer, and I hope it is of some help. This is a super
timekeeping chip which gives good bang for the buck, but I've spent
countless hours the fist time I used one on a project. It was worth sweating
it out though.....hang in there...

Chris

{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamspam_OUTmitvma.mit.edu


More... (looser matching)
- Last day of these posts
- In 2002 , 2003 only
- Today
- New search...