Hello,
I want to measure the 32 kHz XTAL frequency by toggling a GPIO and measuring the frequency by a frequency counter. The nRF52 has got an external crystal connected. But if I measure the frequency, I get around 34 kHz and I noticed that this frequency is there, although I remove the 32 kHz crystal. So the frequency must be created by the internal RC or derived from the 32 MHz crystal. I checked the SDK config but it is correct:
// <e> NRFX_CLOCK_ENABLED - nrfx_clock - CLOCK peripheral driver //========================================================== #ifndef NRFX_CLOCK_ENABLED #define NRFX_CLOCK_ENABLED 1 #endif // <o> NRFX_CLOCK_CONFIG_LF_SRC - LF Clock Source // <0=> RC // <1=> XTAL // <2=> Synth // <131073=> External Low Swing // <196609=> External Full Swing #ifndef NRFX_CLOCK_CONFIG_LF_SRC #define NRFX_CLOCK_CONFIG_LF_SRC 1 #endif
And here is my code to toggle the pin:
static void rtc_evt_handler(nrfx_rtc_int_type_t event)
{
if(event == NRFX_RTC_INT_TICK)
{
/* Set GPIO high */
GPIO_pin_set(TX_TEST, GPIO_state_high);
/* Wait some time */
nrf_delay_us(10);
/* Set GPIO low */
GPIO_pin_set(TX_TEST, GPIO_state_low);
}
}
/* Public functions ----------------------------------------------------------*/
void Test_crystal_32khz_start(void)
{
nrfx_rtc_config_t rtc_config = NRFX_RTC_DEFAULT_CONFIG;
/* Set RTC prescaler */
rtc_config.prescaler = 0;
/* Start internal LFCLK XTAL oscillator */
nrfx_clock_init(clock_evt_handler);
nrfx_clock_lfclk_start();
/* Initialize RTC instance */
nrfx_rtc_init(&rtc_instance, &rtc_config, rtc_evt_handler);
/* Power on RTC */
nrfx_rtc_enable(&rtc_instance);
/* Enable tick event interrupt */
nrfx_rtc_tick_enable(&rtc_instance, true);
Log_print("[OK] %s: Init successful", __FILE__);
while(1)
{
Log_process_single();
}
}
I use the same SDK config for our ongoing project and there I can measure a sine wave on the 32 kHz crystal. But there is a Softdevice running, maybe it is controling the LFCLK sources?
What should I configurate, to force the chip to use the 32 kHz crystal?
Thank you!
Regards.