32.768 Crystal routing to P0.10

We need to route P0.00 - P0.01 crystal clock to P0.10 

Is there a way to do that?

  • I don't have a tested DPPI option to hand for the nRF5340; here is a tested PPI example for the nRF52832/nRF52840 with a guess at a working nRF5340 DPPI:

    #define FCLK_PIN 10  // P0.10
    void TestFCLK(void)
    {
       // Output the 32.768kHz crystal using h/w toggle on FCLK_PIN - will show as 16.384kHz
       nrf_gpio_cfg_output(FCLK_PIN);
       // Select 32kHz clock source
       NRF_CLOCK->LFCLKSRC = CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos;
       // Start 32.768kHz clock
       NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
       NRF_CLOCK->TASKS_LFCLKSTART = 1;
       while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0) ;
       // Clear started event otherwise won't sleep
       NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
       // Start RTC, enable TICK event
       NRF_RTC0->EVTENSET = RTC_EVTENSET_TICK_Msk;
       NRF_RTC0->TASKS_START = 1;
       // Configure GPIOTE to control output pin
       NRF_GPIOTE->CONFIG[0] = GPIOTE_CONFIG_MODE_Task << GPIOTE_CONFIG_MODE_Pos | GPIOTE_CONFIG_POLARITY_Toggle << GPIOTE_CONFIG_POLARITY_Pos | FCLK_PIN << GPIOTE_CONFIG_PSEL_Pos;
    #if 1 // nRF52832
       // Connect TICK event of the RTC to the output pin using PPI and GPIOTE, toggle so 32768/2=16384Hz expected
       NRF_PPI->CH[0].EEP = (uint32_t)&NRF_RTC0->EVENTS_TICK;
       NRF_PPI->CH[0].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[0];
       NRF_PPI->CHEN = PPI_CHEN_CH0_Msk;
    #else // nRF5340 - not tested
       // Connect TICK event of the RTC to the output pin using DPPI and GPIOTE, toggle so 32768/2=16384Hz expected
       NRF_RTC0->PUBLISH_TICK       = (DPPI_PUB_CHIDX_Ch0) | (DPPI_PUB_EN_Msk);
       NRF_GPIOTE->SUBSCRIBE_OUT[0] = (DPPI_SUB_CHIDX_Ch0) | (DPPI_SUB_EN_Msk);
       NRF_DPPIC->CHENSET           = (DPPI_CHENSET_CH0_Set << DPPI_CHENSET_CH0_Pos);
    #endif
    }
    

    Edit: This using-the-dppi-on-the-nrf5340-gpio-toggling might be a useful guide

Related