I have been trying to work with a new chip to me, PIC16F17145. Previously we had gotten 18F26K80 to work but my supply of them is limited and they cost a lot more.
Setting up timer 1 for interrupt to feed the RTC subroutine.
It looks like in the chip data there is not enough options for clocks for Timer 1.
See attached
So to work around, I go directly to setting up the SOSC and selecting the right clock.
SOSCPWR=1SOSCEN=1.....wait500ms'Interrupt Handlers'InitTimer1 ExtOsc, PS1_1'T1CLK = 0x07T1CLK=0x08T1CON=01settimer1,0x8000' 16bit load bit is set to allow'wait500usOnInterruptTimer1OverflowCallRTCStartTimer1
Clock selection 0x07 is the internal 32k clock and the RTC almost runs correctly on that.
Time is off because 32K is not 32768.
Clock selection 0x08 is the correct external crystal sosc and the rtc does Not run on that.
Using InitTimer1 gives selection 0x06 which gives 15 intterrupts when there should be 1.
Yes I tried ExtOsc and it did not work.
I have been trying to work with a new chip to me, PIC16F17145. Previously we had gotten 18F26K80 to work but my supply of them is limited and they cost a lot more.
Setting up timer 1 for interrupt to feed the RTC subroutine.
It looks like in the chip data there is not enough options for clocks for Timer 1.
See attached
So to work around, I go directly to setting up the SOSC and selecting the right clock.
Clock selection 0x07 is the internal 32k clock and the RTC almost runs correctly on that.
Time is off because 32K is not 32768.
Clock selection 0x08 is the correct external crystal sosc and the rtc does Not run on that.
Using InitTimer1 gives selection 0x06 which gives 15 intterrupts when there should be 1.
Yes I tried ExtOsc and it did not work.
Where do I look next?
Thanks,
Mike
Last edit: mmotte 2024-06-10
Have a look at the 16f19156 RTC demo. I needed Microchip to help me understand how it worked!