nrf54L15 RF match

I measured the impedance using a VNA on the J1 socket of the nRF54L15-DK RF: With the RF configured for receive at 78.6 + J7.8, RF transmit continuous carrier at -40dBm: 23.45 + J23, -8dBm continuous carrier: 26 + J22, a deviation of 50 ohms. I've already replaced the matching network with a 0402 package and readjusted it myself. Comparing it with the DK, the result is not 50 ohms. Is this correct? Secondly, I want to measure the frequency offset of the 32768 crystal oscillator and calibrate it to the correct frequency. Are there any recommended methods for doing this with the NRF54L15? I've used a spectrum analyzer to measure the RF frequency offset and adjust it to 32MHz, and I want to use the 32MHz to indirectly calibrate the 32768's frequency offset, but I haven't been able to debug the program. There are too few examples in this area; the NCS only has a few driver calls and no more detailed examples of using these APIs. thank you

uint32_t lfxo_measure(void)
{
    timer_init();
    nrfx_grtc_active_request_set(true);

    /* 分配 DPPI 通道并确认成功 */
    nrfx_err_t err0 = nrfx_dppi_channel_alloc(&dppi, &ch0);
    nrfx_err_t err1 = nrfx_dppi_channel_alloc(&dppi, &ch1);
    printk("DPPI alloc: err0=%d ch0=%u err1=%d ch1=%u\n", err0, ch0, err1, ch1);
    if (err0 != NRFX_SUCCESS || err1 != NRFX_SUCCESS) {
        printk("DPPI channel alloc failed!\n");
        return 0;
    }

	nrfx_gppi_channel_endpoints_setup(
		ch0,
		nrf_grtc_event_address_get(NRF_GRTC, NRF_GRTC_EVENT_COMPARE_5),
		nrfx_timer_task_address_get(&timer, NRF_TIMER_TASK_CAPTURE0)
	);

	nrfx_gppi_channel_endpoints_setup(
		ch1,
		nrf_grtc_event_address_get(NRF_GRTC, NRF_GRTC_EVENT_COMPARE_6),
		nrfx_timer_task_address_get(&timer, NRF_TIMER_TASK_CAPTURE1)
	);

	/* 使能通道 */
	nrfx_gppi_channels_enable(BIT(ch0) | BIT(ch1));

    uint64_t now;
    nrfx_grtc_syscounter_get(&now);
    uint64_t cc0 = now + 30000;
    uint64_t cc1 = cc0 + MEASURE_TICKS;

    /* 先清除事件 */
    nrf_grtc_event_clear(NRF_GRTC, NRF_GRTC_EVENT_COMPARE_5);
    nrf_grtc_event_clear(NRF_GRTC, NRF_GRTC_EVENT_COMPARE_6);

    /* 配置 DPPI 发布/订阅 */
    nrf_grtc_publish_set(NRF_GRTC, NRF_GRTC_EVENT_COMPARE_5, ch0);
    nrf_grtc_publish_set(NRF_GRTC, NRF_GRTC_EVENT_COMPARE_6, ch1);
    nrf_timer_subscribe_set(timer.p_reg, NRF_TIMER_TASK_CAPTURE0, ch0);
    nrf_timer_subscribe_set(timer.p_reg, NRF_TIMER_TASK_CAPTURE1, ch1);
    nrfx_dppi_channel_enable(&dppi, ch0);
    nrfx_dppi_channel_enable(&dppi, ch1);

    /* 设置 CC 值:先写 CCL(禁用通道),再写 CCH(使能通道) */
    NRF_GRTC->CC[5].CCL = (uint32_t)(cc0 & 0xFFFFFFFF);
    NRF_GRTC->CC[5].CCH = (uint32_t)(cc0 >> 32);
    NRF_GRTC->CC[6].CCL = (uint32_t)(cc1 & 0xFFFFFFFF);
    NRF_GRTC->CC[6].CCH = (uint32_t)(cc1 >> 32);

    /* 使能比较事件输出 */
    nrf_grtc_sys_counter_compare_event_enable(NRF_GRTC, 5);
    nrf_grtc_sys_counter_compare_event_enable(NRF_GRTC, 6);

    printk("now=%llu cc0=%llu cc1=%llu\n", now, cc0, cc1);
    printk("CC5L=0x%08X CC5H=0x%08X\n", NRF_GRTC->CC[5].CCL, NRF_GRTC->CC[5].CCH);
    printk("CC6L=0x%08X CC6H=0x%08X\n", NRF_GRTC->CC[6].CCL, NRF_GRTC->CC[6].CCH);

    /* 等待第二个比较事件,加超时保护 */
    uint32_t timeout = 0;
    while (!nrf_grtc_event_check(NRF_GRTC, NRF_GRTC_EVENT_COMPARE_6)) {
        k_msleep(1);
        if (++timeout > 5000) {
            printk("Timeout! GRTC COMPARE_6 never fired.\n");
            goto cleanup;
        }
    }
    printk("GRTC COMPARE_6 fired!\n");

    {
        uint32_t t0 = nrf_timer_cc_get(timer.p_reg, NRF_TIMER_CC_CHANNEL0);
        uint32_t t1 = nrf_timer_cc_get(timer.p_reg, NRF_TIMER_CC_CHANNEL1);
        printk("t0=%u t1=%u\n", t0, t1);

        if (t1 <= t0) {
            printk("Error: Timer capture failed!\n");
            goto cleanup;
        }

        uint32_t diff = t1 - t0;
        uint32_t freq = (uint32_t)(((uint64_t)TIMER_FREQ_HZ * MEASURE_TICKS) / diff);

        /* cleanup */
        nrf_grtc_event_clear(NRF_GRTC, NRF_GRTC_EVENT_COMPARE_5);
        nrf_grtc_event_clear(NRF_GRTC, NRF_GRTC_EVENT_COMPARE_6);
        nrfx_dppi_channel_disable(&dppi, ch0);
        nrfx_dppi_channel_disable(&dppi, ch1);
        nrfx_dppi_channel_free(&dppi, ch0);
        nrfx_dppi_channel_free(&dppi, ch1);
        nrfx_grtc_active_request_set(false);
        nrfx_timer_disable(&timer);
        nrfx_timer_uninit(&timer);

        return freq;
    }

cleanup:
    nrf_grtc_event_clear(NRF_GRTC, NRF_GRTC_EVENT_COMPARE_5);
    nrf_grtc_event_clear(NRF_GRTC, NRF_GRTC_EVENT_COMPARE_6);
    nrfx_dppi_channel_disable(&dppi, ch0);
    nrfx_dppi_channel_disable(&dppi, ch1);
    nrfx_dppi_channel_free(&dppi, ch0);
    nrfx_dppi_channel_free(&dppi, ch1);
    nrfx_grtc_active_request_set(false);
    nrfx_timer_disable(&timer);
    nrfx_timer_uninit(&timer);
    return 0;
}

Parents
  • Hi,

    The nRF54L15 lets you output the LFXO directly on P0.04, and this method is suited for measuring the LFXO accuracy. You can do that using this short application:

    #include <hal/nrf_gpio.h>
    #include <hal/nrf_grtc.h>
    #include <haly/nrfy_grtc.h>
    #include <nrfx_grtc.h>
    
    #include <zephyr/drivers/gpio.h>
    #include <zephyr/kernel.h>
    
    #define PIN_NUM NRF_DT_GPIOS_TO_PSEL(DT_ALIAS(toggler), gpios)
    
    int main(void)
    {
    	/* Output 32.768 kHz clock on pin P0.04 */
    	nrfy_grtc_clkout_set(NRF_GRTC, NRF_GRTC_CLKOUT_32K, true);
    	k_sleep(K_FOREVER);
    
    	return 0;
    }

    Note that if the board use P0.04 for other things you need to modify the board file. If building for the DK which use P0.04 for button 3, add this in an overlay file:

    / {
    	aliases {
    		/delete-property/ sw3;
    	};
    };
    
    /delete-node/ &button3;

    Attached full project for reference: grtc_32768hz_out_nrf54l15.zip.

    Regarding matching, measuring other than 50 ohm at J1 is not unexpected and not indicative of a problem. See this post. Tuning of the match should be done by measuring output power and harmonics.

    Note that if you want assistance on this you can make a private case where you upload your schematics and layout for a HW review, and once that looks good, we may also assist in tuning the HW.

Reply
  • Hi,

    The nRF54L15 lets you output the LFXO directly on P0.04, and this method is suited for measuring the LFXO accuracy. You can do that using this short application:

    #include <hal/nrf_gpio.h>
    #include <hal/nrf_grtc.h>
    #include <haly/nrfy_grtc.h>
    #include <nrfx_grtc.h>
    
    #include <zephyr/drivers/gpio.h>
    #include <zephyr/kernel.h>
    
    #define PIN_NUM NRF_DT_GPIOS_TO_PSEL(DT_ALIAS(toggler), gpios)
    
    int main(void)
    {
    	/* Output 32.768 kHz clock on pin P0.04 */
    	nrfy_grtc_clkout_set(NRF_GRTC, NRF_GRTC_CLKOUT_32K, true);
    	k_sleep(K_FOREVER);
    
    	return 0;
    }

    Note that if the board use P0.04 for other things you need to modify the board file. If building for the DK which use P0.04 for button 3, add this in an overlay file:

    / {
    	aliases {
    		/delete-property/ sw3;
    	};
    };
    
    /delete-node/ &button3;

    Attached full project for reference: grtc_32768hz_out_nrf54l15.zip.

    Regarding matching, measuring other than 50 ohm at J1 is not unexpected and not indicative of a problem. See this post. Tuning of the match should be done by measuring output power and harmonics.

    Note that if you want assistance on this you can make a private case where you upload your schematics and layout for a HW review, and once that looks good, we may also assist in tuning the HW.

Children
No Data
Related