Hello all!
I am using a pic 18f24j11, and I am trying to get the Real-Time clock going. I can't seem to however. Here is my code:
I'm using mikroC, so the relevant config bits are: RTCC Clock Select : INTRC
Basically, I want all of port B to flash as the seconds go by, but nothing happens. In debug mode, the RTCVALL and RTCVALH do not change and on the circuit port B does not flash.
I'm thinking I may have not done something write as far as the internal oscillator goes, but I really can't figure out what it is. If anyone has any insight t would be greatly appreciated!!
I am using a pic 18f24j11, and I am trying to get the Real-Time clock going. I can't seem to however. Here is my code:
Code:
char sec;
void main(){
EECON2 = 0x55;
EECON2 = 0xAA;
RTCCFG.RTCEN = 1;
RTCCFG.RTCWREN = 1;
RTCCFG.RTCSYNC = 0;
RTCCFG.HALFSEC = 0;
RTCCFG.RTCOE = 1;
RTCCFG.RTCPTR0 = 0;
RTCCFG.RTCPTR1 = 0;
RTCCAL = 0x00;
ALRMCFG.ALRMEN = 0;
TRISB = 0x00;
RTCVALL = 0x05;
do{
sec = RTCVALL;
if(sec % 2 == 0){
PORTB = 0xff;
}
PORTB = 0x00;
RTCCFG.RTCPTR0 = 0;
RTCCFG.RTCPTR1 = 0;
}while(1);
}
Basically, I want all of port B to flash as the seconds go by, but nothing happens. In debug mode, the RTCVALL and RTCVALH do not change and on the circuit port B does not flash.
I'm thinking I may have not done something write as far as the internal oscillator goes, but I really can't figure out what it is. If anyone has any insight t would be greatly appreciated!!