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





Bookmarks