Setting LFXODEBOUNCE for nRF52833 in Zephyr

Hi

For use of the nRF52833 above 85°C, the documentation states that the register LFXODEBOUNCE must be set to 'Extended'. In an earlier support thread, it was discussed how to do this using the nRF5 SDK.

What is the recommended way to configure this when using nRF Connect SDK / Zephyr?

Parents
  • Hi,

     

    There is unfortunately no setting for this in the nrf_rtc_timer for the zephyr tick, but you can override this by adding a routine like this:

    #include <zephyr/init.h>
    #include <nrf.h>
    
    static int lfclk_lfxodebounce_set(void)
    {
    	NRF_CLOCK->LFXODEBOUNCE = (CLOCK_LFXODEBOUNCE_LFXODEBOUNCE_Extended << CLOCK_LFXODEBOUNCE_LFXODEBOUNCE_Pos);
    	return 0;
    }
    
    SYS_INIT(lfclk_lfxodebounce_set, EARLY, 0);
     

    For instance to your board file (the most correct approach), or just directly in the project itself.

     

    For debugging purposes, I just added this as a .c file to the hello_world and verified that the function occurred before nrf_rtc_timer.c::sys_clock_driver_init() was called and that the register was indeed set correctly after boot:

    (gdb) print (NRF_CLOCK_Type)*0x40000000
    $2 = {TASKS_HFCLKSTART = 0, TASKS_HFCLKSTOP = 0, TASKS_LFCLKSTART = 0, TASKS_LFCLKSTOP = 0, TASKS_CAL = 0, TASKS_CTSTART = 0, TASKS_CTSTOP = 0, RESERVED = {
        0 <repeats 57 times>}, EVENTS_HFCLKSTARTED = 0, EVENTS_LFCLKSTARTED = 0, RESERVED1 = 0, EVENTS_DONE = 0, EVENTS_CTTO = 0, RESERVED2 = {1, 1, 0, 0, 0}, 
      EVENTS_CTSTARTED = 0, EVENTS_CTSTOPPED = 0, RESERVED3 = {0 <repeats 117 times>}, INTENSET = 0, INTENCLR = 0, RESERVED4 = {0 <repeats 61 times>, 1, 4294967295}, 
      HFCLKRUN = 0, HFCLKSTAT = 65536, RESERVED5 = 0, LFCLKRUN = 1, LFCLKSTAT = 65537, LFCLKSRCCOPY = 1, RESERVED6 = {0, 0, 15, 4294967295, 1, 0 <repeats 52 times>, 
        4294967295, 0, 0, 0, 1048577}, LFCLKSRC = 1, RESERVED7 = {0, 0, 3}, HFXODEBOUNCE = 16, LFXODEBOUNCE = 1, RESERVED8 = {0, 0}, CTIV = 0, RESERVED9 = {3, 39, 0, 0, 1, 
        4294967295, 3, 90}, TRACECONFIG = 0}
     

    Kind regards,

    Håkon

Reply
  • Hi,

     

    There is unfortunately no setting for this in the nrf_rtc_timer for the zephyr tick, but you can override this by adding a routine like this:

    #include <zephyr/init.h>
    #include <nrf.h>
    
    static int lfclk_lfxodebounce_set(void)
    {
    	NRF_CLOCK->LFXODEBOUNCE = (CLOCK_LFXODEBOUNCE_LFXODEBOUNCE_Extended << CLOCK_LFXODEBOUNCE_LFXODEBOUNCE_Pos);
    	return 0;
    }
    
    SYS_INIT(lfclk_lfxodebounce_set, EARLY, 0);
     

    For instance to your board file (the most correct approach), or just directly in the project itself.

     

    For debugging purposes, I just added this as a .c file to the hello_world and verified that the function occurred before nrf_rtc_timer.c::sys_clock_driver_init() was called and that the register was indeed set correctly after boot:

    (gdb) print (NRF_CLOCK_Type)*0x40000000
    $2 = {TASKS_HFCLKSTART = 0, TASKS_HFCLKSTOP = 0, TASKS_LFCLKSTART = 0, TASKS_LFCLKSTOP = 0, TASKS_CAL = 0, TASKS_CTSTART = 0, TASKS_CTSTOP = 0, RESERVED = {
        0 <repeats 57 times>}, EVENTS_HFCLKSTARTED = 0, EVENTS_LFCLKSTARTED = 0, RESERVED1 = 0, EVENTS_DONE = 0, EVENTS_CTTO = 0, RESERVED2 = {1, 1, 0, 0, 0}, 
      EVENTS_CTSTARTED = 0, EVENTS_CTSTOPPED = 0, RESERVED3 = {0 <repeats 117 times>}, INTENSET = 0, INTENCLR = 0, RESERVED4 = {0 <repeats 61 times>, 1, 4294967295}, 
      HFCLKRUN = 0, HFCLKSTAT = 65536, RESERVED5 = 0, LFCLKRUN = 1, LFCLKSTAT = 65537, LFCLKSRCCOPY = 1, RESERVED6 = {0, 0, 15, 4294967295, 1, 0 <repeats 52 times>, 
        4294967295, 0, 0, 0, 1048577}, LFCLKSRC = 1, RESERVED7 = {0, 0, 3}, HFXODEBOUNCE = 16, LFXODEBOUNCE = 1, RESERVED8 = {0, 0}, CTIV = 0, RESERVED9 = {3, 39, 0, 0, 1, 
        4294967295, 3, 90}, TRACECONFIG = 0}
     

    Kind regards,

    Håkon

Children
No Data
Related