Self-diagnostic test for the CPU frequency.
The test consists of monitoring the frequency of a Timer/Counter (TC) using the Real Time Counter (RTC) module as a time reference. Note that the TC has the same clock domain as the CPU and that the RTC module in XMEGA can have a clock source independent from the CPU clock domain. Also, note that CLASSB_FREQ_TEST has to be defined. For more details see Real Time Counter Driver.
The test is implemented as follows:
The TC overflow interrupt increases a counter that can be used as the most significant word (bits 31 to 16) for the TC counter value. Further, there is a configurable limit for the number of overflows. If this is exceeded, the program assumes that the RTC is working correctly and the error handler is called as well.
The test is flexible and it is possible to choose some settings for the TC and RTC. It is important to choose values for CLASSB_RTC_INT_PERIOD, CLASSB_RTC_FREQ, CLASSB_TC_PRESCALER and CLASSB_TC_TOLERANCE so that the frequency of the CPU F_CPU is estimated reliably. Further, there should not be an overflow in CLASSB_TC_COUNT_REF. Suggested values have been included in the documentation.
Modules | |
Settings | |
This should be configured by the user. | |
Internal settings | |
These constants should not be modified by user. | |
Functions | |
Setup and test functions. | |