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----- > > From: pic microcontroller discussion list > > [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of John Brown > > Sent: Wednesday, June 05, 2002 8:28 AM > > To: PICLIST@MITVMA.MIT.EDU > > Subject: [PIC]: 877 and Dallas 1302 > > > > > > 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: john.brown@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 >mailto:piclist-unsubscribe-request@mitvma.mit.edu _______________________________________________________________________ John Brown PhD (Clinical Psychology) candidate Email: john.brown@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 mailto:piclist-unsubscribe-request@mitvma.mit.edu