verifying 32kHz crystal accuracy

We have a custom board that is using the RTC with an external 32.768kHz crystal.  I would like to verify the accuracy and tune the capacitors if necessary.  I want to verify that what I am doing is reasonable.

We are using Zephyr.  I have set up

CONFIG_CLOCK_CONTROL_NRF_K32SRC_XTAL=y

static struct k_timer mTimer;

static void on_timer(struct k_timer *timer)
{
    pin_traces_auto_toggle(tp_pin_7);
   // pin_traces_toggle(tp_pin_6,k_is_in_isr());
}

int main(void)
{
    __ASSERT_NO_MSG(log_initialize());
    __ASSERT_NO_MSG(pin_traces_initialize());

    k_timer_init(&mTimer, on_timer, NULL);
    k_timer_start(&mTimer, K_SECONDS(1), K_SECONDS(1));

    return 0;
}

This timer will be based on the 32.768kHz crystal, correct?  I am watching the GPIO signal on what we have defined as test point 7 over a long period to verify the accuracy.  I get (basically) a 1 second toggle off this pin.  Is it reasonable to use this for checking crystal accuracy?

Parents Reply Children
  • Hi, I'm trying to use this example for the same purpose as the OP, but the example gives several build errors, including

    .../nrf/subsys/debug/ppi_trace/ppi_trace.c: In function 'get_gpiote':
    .../nrf/subsys/debug/ppi_trace/ppi_trace.c:56:22: error: unknown type name 'nrfx_gpiote_t'

    and

    .../nrf/subsys/debug/ppi_trace/ppi_trace.c:129:13: error: too many arguments to function 'nrfx_gpiote_channel_alloc'
      129 |         if (nrfx_gpiote_channel_alloc(gpiote, &channel) != NRFX_SUCCESS) {
          |             ^~~~~~~~~~~~~~~~~~~~~~~~~
    .../modules/hal/nordic/nrfx/drivers/include/nrfx_gpiote.h:185:12: note: declared here
      185 | nrfx_err_t nrfx_gpiote_channel_alloc(uint8_t * p_channel);

    I'm using SDK 2.6.0.

    Thanks!

Related