Menu

RTCC: Real-Time Clock/Calendar library for Microchip PIC microcontroller

Anobium
2017-12-15
2017-12-15
  • Anobium

    Anobium - 2017-12-15

    Added Real-Time Clock/Calendar (RTCC) library for Microchip PIC microcontroller to Great Cow BASIC.

    The library has the same capabilities as the other RTCC libraries but this support the Microchip PIC Internal RTCC.

    Methods

    The Public methods are shown below:

    rtcc_TimeGet    - MPLAB equivilent method. Return values in global variables as follows:
         tm_year, tm_mon, tm_wday, tm_mday, tm_hour, tm_min, tm_sec
    rtcc_GetFormatted_Value converts byte data to tens and digites ( rtcc_data as byte , out digits , out tens)
    rtcc_SetClock(hour, minute, second, DOW, date, month, year)
    rtcc_SetTime(hour, minute, second)
    rtcc_SetDate(DOW, date, month, year)
    rtcc_ReadClock(hour, minute, second, a.m.|p.m., DOW, date, month, year)
    rtcc_ReadTime(hour, minute, second, a.m.|p.m.)
    rtcc_ReadDate(DOW, date, month, year)
    rtcc_Enable ( true or false )
    rtcc_ReadAlarm ( hour, minute, second, DOW, date ). Return values
    rtcc_SetAlarm ( hour, minute, second, DOW, date )
    rtcc_SetAlarmMask ( alarmAssertionMatch )
    rtcc_ClearAlarm  unset the alarm )
    rtcc_ReStartAlarm  reset an existing alarm
    rtcc_GetDecimalValue ( value ) returns a number value in tens and digits
    rtcc_DecToBcd  Convert pure decimal number to binary coded decimal
    rtcc_BcdToDec  Convert binary coded decimal to pure decimal
    

    The library will be in future releases but is available if needed before the next release - just ask.

    Demos

    If you search GITHUB for RTCC you will find the demonstrations for the 16F19156

    https://github.com/Anobium/Great-Cow-BASIC-Demonstration-Sources/find/master

    Thanks

    My thanks go to William as he helped me crack the initilisation process.

    Enjoy

     
  • Moto Geek

    Moto Geek - 2017-12-15

    This is very cool! I went to the microchip site to use their parametric search to see which 8 bit pics have the RTCC, but that is not one of their searchable items, that I can find anyway. How can you find which pics have this capability?

     
  • William Roth

    William Roth - 2017-12-15

    It is in the parametric search, At the top ritght click on "Show All Specs" then it will show up.

     
  • Chris Roper

    Chris Roper - 2017-12-15

    The problem with the Microchip RTC is the lack of a Battery pin to keep the Internal RTC alive on power loss. It is not much more than a Clock Xtal on the Timer 1 Input, but it sounds good in marketing litrature to call it an onboard RTC :)

     
    • William Roth

      William Roth - 2017-12-15

      The RTCC included with the PIC16F191xx series of chips is a "real" RTCC module
      and is much more than a crystal on timer1.

      Features:

      • Time: Hours, Minutes and Seconds
      • 24-hour Format (Military Time)
      • Calendar: Weekday, Date, Month and Year
      • Year Range: 2000 to 2099
      • Leap Year Correction
      • Configurable Alarm
      • BCD Format for Compact Firmware
      • Half-second Synchronization and Visibility
      • User Calibration with Auto-Adjust
      • Multiple Clock Sources
      • Low-Power Optimization
      • Battery Support (V_Bat Pin)

      Have a look at the Datasheet (Section 24)

      PIC16F191xx Datasheet

       
      • Anobium

        Anobium - 2017-12-15

        Yep - the library is very comprehensive covers all the functionality includingng the alarm and the interrupt. I did check the library will support the 18f RTCC also but I cannot test.

        Features:

        • Time: Hours, Minutes and Seconds
        • 24-hour Format (Military Time)
        • Calendar: Weekday, Date, Month and Year
        • Year Range: 2000 to 2099
        • Leap Year Correction
        • Configurable Alarm
        • BCD Format for Compact Firmware
        • Half-second Synchronization and Visibility
        • User Calibration with Auto-Adjust
        • Multiple Clock Sources
        • Low-Power Optimization
        • Battery Support (V_Bat Pin)

         
  • Anobium

    Anobium - 2017-12-15

    The problem with the Microchip RTC is the lack of a Battery pin to keep the Internal RTC alive on power loss. It is not much more than a Clock Xtal on the Timer 1 Input, but it sounds good in marketing litrature to call it an onboard RTC :)

    Not the case.

    From the datasheet:

    24.3 VBAT Operation
    This device is equipped with a VBAT pin that allows the
    user to connect an external battery or Supercap. In the
    event of the VDD supply failing or dropping below the
    supply voltage level on the VBAT pin, the power source
    connected to the VBAT pin will keep the SOSC and
    RTCC blocks running. VBAT is enabled via the VBATEN
    bit in Configuration Word 1.

    This works a treat.

     

    Last edit: Anobium 2017-12-15
  • Moto Geek

    Moto Geek - 2017-12-15

    Wow, this is really great now with the VBAT. Eliminates the DS321 on some future projects... Nice job there Evan and William!

     
    • Anobium

      Anobium - 2017-12-15

      Never get too exicited! The library may need tweaking!

       
  • Chris Roper

    Chris Roper - 2017-12-15

    Thanks Bill and Anobium,

    I must take a look and get an order in for samples.

    I requested that feature at Last year's conference and they said no, not available and not planned.
    So either the engineers were told to keep mum, or as usual the right hand doesn't know what the left is doing .

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.