Alarm Interrupt not working with 16F19175

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

Alarm Interrupt not working with 16F19175

Postby aru » Wed Dec 19, 2018 2:23 pm

CX8 V2.0

SK40C can be used with 16F19175 which comes with built-in RTCC. No more external RTCC chips required. My Real Time keeping functions are all working fine in the hardware.

Was testing for the RTCC interrupt when Real Time matches and Alarm Time setting.
Based on the settings, an interrupt is expected 10 seconds after programming the hardware.
But there is no interrupt execution.
Followed the Application Note TB3203A for RTCC Module Initialization steps.
Code lines are given herewith.
Appreciate any help.

#pragma config FEXTOSC = ECM, WDTE = OFF, MCLRE = ON, LVP = OFF
#include <xc.h>
#define _XTAL_FREQ 4000000

void main(void)
    ANSELE = 0;
    TRISEbits.TRISE0 = 0;
    RTCCONbits.RTCWREN = 1;         //enable write
    RTCCONbits.RTCEN = 0;           //disable run
    RTCCONbits.RTCCLKSEL = 0x00;    //select SOSC as RTC clock source
    YEAR = 0x18; MONTH = 0x5; WEEKDAY = 0x2; DAY = 0x22;
    HOURS = 0x12; MINUTES = 0x30; SECONDS = 0x0;
    RTCCAL = 0x00;
    ALRMCONbits.ALRMEN = 0; // alarm disabled
    ALRMRPT = 0xFF;         // Repeat
    ALRMMTH = 0x5; ALRMWD = 0x2; ALRMDAY = 0x22;
    ALRMHR = 0x12; ALRMMIN = 0x30; ALRMSEC = 0x10;
    ALRMCONbits.ALRMEN = 1;     //enable alarm
    ALRMCON = 0xC8;             //Every 10 sec, Chime enabled
    RTCCONbits.RTCEN = 1;       //enable RTCC module
    while(!RTCCONbits.RTCEN);   //wait till RTCC starts to run
    RTCCONbits.RTCWREN = 0;     //avoid inadvertent write
    PIR8bits.RTCCIF = 0;       
    PIE8bits.RTCCIE = 1;
    INTCONbits.PEIE = 1;
    INTCONbits.GIE = 1;

void __interrupt () ALRM(void)
    if(PIE8bits.RTCCIE && PIR8bits.RTCCIF)
        LATEbits.LATE0 = 1;
        LATEbits.LATE0 = 0;
        PIR8bits.RTCCIF = 0;    //clear flag
Posts: 21
Joined: Fri Jan 05, 2018 2:53 pm

Re: Alarm Interrupt not working with 16F19175

Postby aru » Fri Dec 21, 2018 9:08 am

Based on help from another Forum, there a Family Silicon Errata from Microchip that specifies that Alarm will not occur if the lower nibble of ALRMSEC register is loaded with 0x0.
If loaded with value other than 0x0, the Alarm interrupt works without any issues.
Can consider this case closed.

Hope this information will be of help to those who would use this family of devices for RTCC function.
Posts: 21
Joined: Fri Jan 05, 2018 2:53 pm

Re: Alarm Interrupt not working with 16F19175

Postby ober » Fri Dec 21, 2018 12:20 pm

Hi Aru, thanks for sharing the info.

We have experienced similar bug in using new model of PIC and Errata do help.
Ober Choo
Cytron Technologies Sdn Bhd
User avatar
Posts: 1470
Joined: Wed Apr 15, 2009 1:03 pm

Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 2 guests