Menu

MicroChipRTCC.h problems fixed

2018-07-28
2018-07-30
  • Clint Koehn

    Clint Koehn - 2018-07-28

    Edited by Anobium: For a detail discussion to the 16f RTCC issues and hopefully the resolution. See https://sourceforge.net/p/gcbasic/discussion/579126/thread/8ea6a50e/?

    Original post by Clint: Undedited is shown below.


    The MicroChipRTCC.h had numerous errors in it, al least for my PIC16F19176 chip I'm using.

    1 - Does not work with #starup. I had to remark that out and place "rtcc_Initialize" right before my main loop otherwise it would lock up the chip.

    2 - There were also some RTCEN before RTCWREN. RTCWREN must be before RTCEN. Fixed

    3 - The "wait unit RTCSYNC = 0" would also just lock the chip up. i had to replace that with a 200us delay then it worked. I set up a "rtcc_TimeDelay" define that can be changed before calling rtcc_Initialize.

    4 - There were some "rtcc_TimeGet" function assigns in subs that had nothing to do with them. I removed them.

    5 - There were also some code (see below) in subs again that had nothing to do with the sub. I removed them.

        if ( RTCSYNC = 0 ) then
            rtcc_TimeGet =  false        
        end if
    

    6 - There were 3 function calls in routine "rtcc_SetTime" that were missing parantheses. Fixed.

    7 - VBATEN is inverted so it needs to be "#config VBATEN=Off" to turn on battery support.

    Later,
    Clint

     

    Last edit: Anobium 2018-07-29
  • Clint Koehn

    Clint Koehn - 2018-07-28

    Still musn't have everything right. The battery kept the time the power was turned off, but did not keep SOSC working. Need to do some more reading I guess.

    Later,
    Clint

     
  • Anobium

    Anobium - 2018-07-28

    The startup behavious is concerning. Not seen this before. And, probably the clock is not starting correctly.

    This is code generated with Microchip support so for RTCSYNC not to work means the clock is not is started.

    As this code is with Microchip support with open tickets I truly am waiting for them to advise.

     

    Last edit: Anobium 2018-07-29
  • Clint Koehn

    Clint Koehn - 2018-07-28

    The #startup simply did not work. It locked my chip up. The RTCSYNC did not work. It locked my chip up. When I removed both of those the RTC worked as far as being able to retrieve and set the time and keep time. All running off of the SOSC. Of course, the VBAT hasn't kept the clock running when the power is removed. It looks like it doesn't matter if VBATEN is ON or OFF. It still saves the time just before power is lost. It is frusterating.

     
  • Anobium

    Anobium - 2018-07-29

    Moved to Open Discussion Forum.

    The .h posted will be merged, if these changes are appropiate, when we have resolved the RTCC issues - we are working with Microchip to resolve (as of July 2018).

    See thread https://sourceforge.net/p/gcbasic/discussion/579126/thread/8ea6a50e/?limit=250#7644 for updated on the Microchip/Great Cow BASIC resolution to this issue.

     

    Last edit: Anobium 2018-07-29
  • Peter

    Peter - 2018-07-30

    I use MCP7940N RTCs in some projects, and I've sometimes had problems with the battery backup not working when power is lost, but I put this down to user incompetence.
    If I get time I will do some tests to check there isn't a similar bug with these.

     

Log in to post a comment.