Rtcc


Closed Thread
Results 1 to 5 of 5

Thread: Rtcc

  1. #1
    Join Date
    Jun 2008
    Location
    Chicago suburb
    Posts
    5

    Default Rtcc

    I have not programmed a pic for several years.
    I want to use a 18F46J11 and I want to use the
    on chip RTCC as a free running 1 sec timer
    with the RB1 port giving me every sec an output
    (0.5s on 0.5s off). This is from the spec sheets.
    In my design I have a 32.768 kHz crystal on the
    Timer1 external clock input Pin RC0/RC1.
    How do I initiate the timer in PBP?
    Any help is greatly appreciated, however my
    feedback how things worked out will have to
    wait a bit since I am currently laying out the pcb
    and I have to know if I have to make changes
    to my design.

    Thank you for your help

    Gerd

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Rtcc

    I am not familiar with that chip, but for the timer I would use DT's Instants
    http://darreltaylor.com/DT_INTS-18/home.html

    And do you really layout the PCB before testing on a breadboard? You are braver than me
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Jun 2008
    Location
    Chicago suburb
    Posts
    5


    Did you find this post helpful? Yes | No

    Default Re: Rtcc

    thanks for the link but I don't want to use interups since the accuracy is not important.
    I just want the 1 sec rtcc output.
    I may have written poorly in my initial request but I do breadbord before finishing the
    pcb. I do temporary lay-outs to see how everything fits.

    Gerd

  4. #4
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default Re: Rtcc

    This was tested on a PIC18F25J11 running at 3V, but should work on your 46J11. Note it was tested with PBP3, but can easily be modified to work with earlier versions.
    Code:
      #CONFIG
       CONFIG OSC = INTOSC 
       CONFIG LPT1OSC = OFF 
       CONFIG CP0 = OFF 
       CONFIG WDTEN = OFF 
       CONFIG XINST = OFF
       CONFIG IOL1WAY = OFF
       CONFIG STVREN = OFF 
       CONFIG T1DIG = OFF 
       CONFIG FCMEN = OFF 
       CONFIG WDTPS = 512 
       CONFIG RTCOSC = T1OSCREF
      #ENDCONFIG 
    
      ' Connect a 32.768 kHz watch crystal between pins 11 & 12 T1CKI & T1OSI
      ' with caps to match your crystal capacitance.
      ' 11        12
      '  |---||---|
      '  |  xtal  |
      ' _|_      _|_
      ' ___      ___  2 x 12pF caps
      '  |        |
      ' gnd      gnd
       
      DEFINE OSC 4 
      OSCCON = %01100000  ' using 4MHz internal osc
      
      ' // disable A/D & setup Timer1 for RTCC //
      ANCON0 = $ff
      ANCON1 = $1f        ' disable A/D on all analog pins 
      T1CON = %10001101   ' ext 32.768 kHz xtal, 1:1 prescale, no synch, 8-bit, timer1 on 
      TRISB.1 = 0         ' clear TRISB.1 for RTCC 1Hz output  
      PADCFG1 = %00000010 ' RTCC seconds clock is selected for output on the RTCC pin
      RTCCFG.2 = 1        ' set RTCC output enable bit
       
      EECON2 = $55        ' unlock sequence to enable writes to RTCC registers
      EECON2 = $AA
      RTCCFG.5 = 1        ' set bit 5 for RTCC write enable   
      RTCCFG.7 = 1        ' set bit 7 for RTCC clock enable 
      
      EECON2 = $55        ' lock sequence to disable writes to RTCC registers
      EECON2 = $AA
      RTCCFG.5 = 0        ' clear bit 5 to lockup & disable RTCC writes
    
    Here:
      GOTO Here
     
      END
    It produces a very accurate 1Hz clock out on RB1.

    This is a working test version of a serial clock & 3 x 10KHz PWM outputs with the same PIC CLOCK_25J11.txt

    Hope this helps.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  5. #5
    Join Date
    Jun 2008
    Location
    Chicago suburb
    Posts
    5


    Did you find this post helpful? Yes | No

    Default Re: Rtcc

    Bruce

    Thank you very much for your help. I had internet problems on my home computer
    so could not receive your response over the weekend. I am using now my work computer.
    I am going to try it out and I believe the onboard rtcc is the same on all 18F chips.
    Thanks again and best regards

    Gerd

Similar Threads

  1. Mcp79410 rtcc
    By keymuu in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 17th July 2012, 05:36
  2. 18F devices RTCC Interrupt
    By readitaloud in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 26th July 2011, 10:39
  3. Support for RTCC
    By fowardbias in forum PBP Wish List
    Replies: 0
    Last Post: - 28th April 2011, 16:49
  4. 18F25J11 RTCC & remappable pin options
    By jonas2 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 27th February 2011, 10:20
  5. 18F25J11 RTCC & remappable pin options
    By Bruce in forum Code Examples
    Replies: 13
    Last Post: - 26th February 2011, 10:51

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