This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Use lower frequency(32 KHz) to measure higher frequency(8 MHz) ticks/counts for 1 second

Hi all,

I want to measure higher frequency (8 MHz) count/ticks by using the lower frequency (32 KHz) is there is any method to do it or any examples.

I want to measure the count as shown in the figure.

Thanks in advance..

  • Hi,

    There is no count mode on the low frequency timers (RTC), this is only available in the high frequency TIMER peripherals. Also, how should the lower frequency timer be able to count the higher frequency signal? You would lose all the ticks of the high frequency signel that is between each clock cycle of the low frequency timer.

    Best regards,
    Jørgen

  • My bad. I wanted to measure a lower frequency using higher frequency. The intention is to calibrate the low frequency clock (32kHz LFCLK) using high frequency clock (64MHz HFCLK). I understand there could be 2 ways to do it

    1) Count the ticks of HFCLK in a single LFCLK period. Hence had asked this question

    2) Additionally, i also figured out that there is a calibration timer for this purpose (which uses CTSTART,CTSTOP,CTTO). I believe this would be a more straightforward way of achieving what i intend to do.

    Is there any sample code that i could look into for this calibration, especially using approach 2.

    Thanks,

  • Please have a look at my answer in this thread.

    You can calibrate the low frequency RC oscillator by triggering the task TASKS_CAL, and calibration can be done at a given interval by setting CTIV, and triggering CT_START task.

  • Hi Jorgen,

    Is this the way to calibrate RC oscillator .

    	NRF_CLOCK->TASKS_HFCLKSTART;
    	//NRF_CLOCK->TASKS_LFCLKSTART;
    	NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_RC << CLOCK_LFCLKSRC_SRC_Pos);
    	NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
    	NRF_CLOCK->TASKS_LFCLKSTART    = 1;
    	
    	NRF_CLOCK->TASKS_CAL=1;
    	printf("task cal\n \r");
    	printf("ctiv\n\r");
    	NRF_CLOCK->TASKS_CTSTART;
    	NRF_CLOCK->CTIV=10;
    //	NRF_CLOCK->EVENTS_DONE;
    //	NRF_CLOCK->EVENTS_CTTO;
    	NRF_CLOCK->TASKS_CTSTOP;
    
    
    	//nrf_delay_ms(1000);
    	while(NRF_CLOCK->CTIV==0)
    	{
    		nrf_delay_ms(100);
    		printf("Calibrating done\n\r");
    	}
    	printf("Calibration\n\r");

    or i am going in the wrong direction. By using this i am not getting any output. If i am going wrong please tell me where i am going wrong.

    Thank..,

  • No, this is not correct. If you trigger the calibration task (NRF_CLOCK->TASKS_CAL=1;), a NRF_CLOCK->EVENTS_DONE event is generated. This is what you should wait for in a while loop. You can run the calibration timer to get an event when you should calibrate the clock (EVENTS_CTTO), you then need to trigger the calibration task and start the timer again. Also note that you need to write 1 to the registers to trigger a task.

Related