Alarm Interrupt not working with 16F19175
Posted: Wed Dec 19, 2018 2:23 pm
MPLABX V5.10
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.
Thanks
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.
Thanks
- CODE: SELECT_ALL_CODE
#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;
while(1);
}
void __interrupt () ALRM(void)
{
if(PIE8bits.RTCCIE && PIR8bits.RTCCIF)
{
LATEbits.LATE0 = 1;
__delay_ms(2000);
LATEbits.LATE0 = 0;
PIR8bits.RTCCIF = 0; //clear flag
}
}