14.10.1.3.2 Workflow
- Set RTC period to 2000ms (two seconds) so that it will overflow and reset back to zero every two seconds.
rtc_count_set_period(&rtc_instance, 2000);
- Enter an infinite loop to poll the RTC driver to check when a comparison match occurs.
while
(
true
) {
- Check if the RTC driver has found a match on compare channel 0 against the current RTC count value.
if
(rtc_count_is_compare_match(&rtc_instance, RTC_COUNT_COMPARE_0)) {
- Once a compare match occurs, perform the desired user action.
/* Do something on RTC count match here */
port_pin_toggle_output_level(LED_0_PIN);
- Clear the compare match, so that future matches may occur.
rtc_count_clear_compare_match(&rtc_instance, RTC_COUNT_COMPARE_0);