Skip to content

microchip-pic-avr-examples/attiny817-rtc-crystal-error-compensation-mplab

Repository files navigation

MCHP

RTC Crystal Error Compensation

This example code demonstrates how to do compensation for static drift. The drift is not measured, as it is static. Temperature is therefore not considered here. As this example uses a known value for the drift, the direction of the drift is also known. The RTC is configured to generate an interrupt every second. In the ISR, a variable keeps track of the cumulative error. If the error is larger than one 32.768 kHz clock cycle, the RTC period is reduced to compensate for this.

This example is based on the Application Note AN2711 - Real-Time Clock Calibration and Compensation on AVR® Microcontrollers, which should be referred to for a more detailed understanding of the concepts.

Related Documentation

Software Used

Hardware Used

Setup

  1. The crystal on the ATtiny817 Xplained Pro board is by default not connected to the TOSC pins, as they are used for UART communication. To connect the pins, remove resistors R307 and R308 and place them on the footprints of R312 and R313. Refer to ATtiny817 Xplained Pro User's Guide for more information on how to do this.

Operation

  1. Connect the board to the PC.

  2. Download the zip file or clone the example to get the source code.

  3. Open the project in MPLAB X IDE.

  4. Build the solution and program the ATtiny817.

Conclusion

This example has now illustrated a way of compensating for static drift.

About

This example code demonstrates how to do compensation for static drift. A known value for the drift will be used.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •