34.3.5 System Clock Measurement with UPDI

It is possible to use the UPDI to get an accurate measurement of the system clock frequency by utilizing the UPDI event connected to TCB with Input Capture capabilities. A recommended setup flow for this feature is given by the following steps:
  • Set up TCBn.CTRLB with setting CNTMODE = 0x3, Input Capture Frequency Measurement mode
  • Write CAPTEI = 1 in TCBn.EVCTRL to enable Event Interrupt. Keep EDGE = 0 in TCBn.EVCTRL
  • Configure the Event System to route the UPDI SYNCH event (generator) to the TCB (user)
  • For the SYNCH character used to generate the UPDI events, it is recommended to use a slow baud rate in the range of 10-50 kbps to get a more accurate measurement of the value captured by the timer between each UPDI event. One particular thing is that if the capture is set up to trigger an interrupt, the first captured value must be ignored. The second captured value based on the input event must be used for the measurement. See Figure 34-18 for an example using 10 kbps UPDI SYNCH character pulses, giving a capture window of 200 µs for the timer.
  • It is possible to read out the captured value directly after the SYNCH character by reading the TCBn.CCMP register, or the value can be written to memory by the CPU once the capture is done. For more details, refer to the TCB - 16-bit Timer/Counter Type B section.
Figure 34-18. UPDI System Clock Measurement Events