Menu

Can' get SOSC to work on PIC16F17145

Help
mmotte
2024-06-10
2024-06-10
  • mmotte

    mmotte - 2024-06-10

    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=1
    SOSCEN=1
    
    .....
    
     wait 500 ms
      'Interrupt Handlers
      'InitTimer1 ExtOsc, PS1_1
      'T1CLK = 0x07
      T1CLK = 0x08
      T1CON = 01
      settimer 1,0x8000       ' 16bit load bit is set to allow
      '
      wait 500 us
      On Interrupt Timer1Overflow Call RTC
    
      StartTimer 1
    

    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
  • Anobium

    Anobium - 2024-06-10

    Have a look at the 16f19156 RTC demo. I needed Microchip to help me understand how it worked!

     

Log in to post a comment.