Help with RTCC Module - 18F26J50


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    166

    Default Help with RTCC Module - 18F26J50

    Hi All,

    I am having difficulties getting a 1Hz pulse from the output of the RTCC module on a PIC18F26J50.
    I have a 32.768kHz signal being fed directly to the T1CKI input from my signal generator to act as the clock source.
    I have a 2Hz signal being generated via the main program look and fed to RB2 to show that the program is alive and running.
    RB2 feeds to an LED via a suitable current resistor to ground - this works perfectly and the LED flashes as expected.
    I have the same LED/current resistor connected from the RTCC output (RB1) to ground - this this pin is always low!
    My program is as follows:

    Code:
    '***********************************************************************
    '*  Name    : RTCC_18F26J50_Test.pbp                                   *
    '*  Author  : Barry Phillips                                           *
    '*  Notice  : Copyright (c) 2017 Baztronics                            *
    '*          : All Rights Reserved                                      *
    '*  Date    : 12/09/2017                                               *
    '*  Version : 1.0                                                      *
    '*  Notes   : Program to generate a 1Hz output on RB1 (pin 22) using   *      
    '*          : RTCC module on PIC18F26J50. A 32.768kHz signal is fed to *
    '*          : the T1CKI (pin 11) to drive the RTCC. A 2Hz signal is    *
    '*          : generated in the main program loop and output on RB2     *
    '*          : (Pin 23) to indicate the program is alive and running.   *
    '***********************************************************************
    
    ;----[Device Configuration]-----------------------------------------------------
    #CONFIG
        CONFIG  WDTEN = OFF            ; Disabled
        CONFIG  PLLDIV = 1             ; Divide by 1 (4 MHz oscillator input)
        CONFIG  STVREN = OFF           ; Disabled
        CONFIG  XINST = OFF            ; Disabled
        CONFIG  DEBUG = OFF            ; Disabled
        CONFIG  CPUDIV = OSC1          ; No CPU system clock divide
        CONFIG  CP0 = OFF              ; Program memory is not code-protected
        CONFIG  OSC = INTOSC           ; Internal Oscillator
        CONFIG  T1DIG = OFF            ; Secondary Oscillator clock source may be not selected
        CONFIG  LPT1OSC = OFF          ; High-power operation
        CONFIG  FCMEN = OFF            ; Disabled
        CONFIG  IESO = OFF             ; Disabled
        CONFIG  WDTPS = 512            ; 1:512
        CONFIG  DSWDTOSC = INTOSCREF   ; DSWDT uses INTRC
        CONFIG  RTCOSC = T1OSCREF      ; RTCC uses T1OSC/T1CKI
        CONFIG  DSBOREN = OFF          ; Disabled
        CONFIG  DSWDTEN = OFF          ; Disabled
        CONFIG  DSWDTPS = G2           ; 1:2,147,483,648 (25.7 days)
        CONFIG  IOL1WAY = OFF          ; The IOLOCK bit (PPSCON<0>) can be set and cleared as needed
        CONFIG  MSSP7B_EN = MSK7       ; 7 Bit address masking mode
        CONFIG  WPFP = PAGE_0          ; Write Protect Program Flash Page 0
        CONFIG  WPEND = PAGE_WPFP      ; Page WPFP<5:0> through Configuration Words erase/write protected
        CONFIG  WPCFG = OFF            ; Configuration Words page not erase/write-protected
        CONFIG  WPDIS = OFF            ; WPFP<5:0>/WPEND region ignored
      #ENDCONFIG
    
    ;----[DEFINEs]------------------------------------------------------------------
    DEFINE OSC 4
    
    ;----[Aliases]------------------------------------------------------------------
    
    ;----[Variables]----------------------------------------------------------------
    
    ;----[Initialize]---------------------------------------------------------------
    OSCCON = %01101100					;4MHz Oscillator
    ANCON0 = %11111111					;All pins configured as a digital I/O
    ANCON1 = %00011111					;Band gap turned off
    									;All other pins configured as a digital I/O
    T1GCON.7 = 0						;Timer1 gate disabled
    TCLKCON.4 = 1                       ;Device is clocked by T1OSC/T1CKI
    T1CON = %10000101   				;T1CKI Input
    									;1:1 prescale
    									;no sync
    									;8-bit
    									;Timer1 on
    TRISB = 0         					;All PORTB as digital output  
    PADCFG1 = %00000010 				;RTTC Seconds clock output on the RTCC pin
    RTCCFG.2 = 1        				;Enable RTCC output
    EECON2 = $55        				;unlock sequence to enable writes to RTCC registers
    EECON2 = $AA
    RTCCFG.5 = 1        				;Enable RTCC write   
    RTCCFG.7 = 1        				;Enable RTCC module
    EECON2 = $55        				;lock sequence to disable writes to RTCC registers
    EECON2 = $AA
    RTCCFG.5 = 0        				;Disable RTCC write
    
    ;----[Main Program Loop]--------------------------------------------------------
    Main:
        PORTB.2 = 1
        PAUSE 250
        PORTB.2 = 0
        PAUSE 250
    GOTO Main
    
    END


    I know the TIMER1 settings are correct and the clock source is operational because I have proven operation using a separate program with DT_INTS-18 and a flashing LED ISR routine.
    This only leaves the RTCC register setting which have been copied directly from a previous RTCC post http://www.picbasic.co.uk/forum/show...highlight=RTCC
    I have spent days trying to work out what I have done wrong - alas, all to no avail

    Any assistance to help resolve this problem would be greatly appreciated.

    Cheers
    Barry
    VK2XBP

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,516


    Did you find this post helpful? Yes | No

    Default Re: Help with RTCC Module - 18F26J50

    Hi Barry,
    I've never used the RTCC module so this is pure speculation on my behalf.
    As far as I can see the RTCC module is meant to be clocked from the TMR1 oscillator (or an internal RC oscillator). Clocking TMR1 with an external signal to T1CKI is not the same thing - I don't think. The RTCC doesn't really use TMR1 so the fact that you see TMR1 "running" doesn't mean the RTCC is.

    Again, purely speculation and interpretation of the datasheet, no personal experience here.

    Happy programmers day!

    /Henrik.

  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    2,383


    Did you find this post helpful? Yes | No

    Default Re: Help with RTCC Module - 18F26J50

    the data sheet says
    If the Timer1 oscillator will be used as the clock source
    for the RTCC, make sure to enable it by setting
    T1CON<3> (T1OSCEN). The selected RTC clock can
    be brought out to the RTCC pin by the
    RTSECSEL<1:0> bits in the PADCFG register.
    which is missing in your code
    T1CON = %10000101
    try
    T1CON = %10001101
    Warning I'm not a teacher

  4. #4
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    166


    Did you find this post helpful? Yes | No

    Default Re: Help with RTCC Module - 18F26J50

    Thanks Henrik and Richard for responding to my post so quickly.

    Henrik - your speculation and my speculation differ. Thanks for offering an opinion.

    Richard - I set the T1CON register that way on purpose BUT, I also tried your suggestion. Neither fixed the problem

    My plan now is to cut my losses and go to a new design using an I2C RTCC with a PIC16F1828.
    I will keep you all posted on my progress.

    Cheers
    Barry
    VK2XBP

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    2,383


    Did you find this post helpful? Yes | No

    Default Re: Help with RTCC Module - 18F26J50

    maybe its a mistake to set the !T1SYNC bit.
    I notice the example code does not set that bit.
    one thing is for sure the Timer1 oscillator will not run if its not enabled ,after that its all guess work for me
    Warning I'm not a teacher

  6. #6
    Join Date
    May 2013
    Location
    australia
    Posts
    2,383


    Did you find this post helpful? Yes | No

    Default Re: Help with RTCC Module - 18F26J50

    how is the 32k signal coupled to the t1clk ?

    if I recall correctly to sync the t1osc with the ext signal the coupling needs to be a capacitive
    one . try about .01uF
    make sure the other xtal pin is not loaded up either, or you may need to drive that pin too
    can't remember.
    why not just put a rock on it anyway, there're cheap

    google up using tcxo with pic to get some better info
    Warning I'm not a teacher

Similar Threads

  1. Dts int 18f26j50
    By mpardinho in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 2nd October 2013, 10:02
  2. 18f26j53 rtcc
    By fowardbias in forum General
    Replies: 0
    Last Post: - 10th March 2013, 16:34
  3. Rtcc
    By Gerd in forum General
    Replies: 4
    Last Post: - 5th November 2012, 21:15
  4. WRITECODE and BLOCKSIZE on 18F26J50
    By proximo in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 22nd June 2011, 12:16
  5. Support for RTCC
    By fowardbias in forum PBP Wish List
    Replies: 0
    Last Post: - 28th April 2011, 16:49

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts