nRF5340 clock sources

Hello !

It is not so clear default clock sources on nRF5340 app and net cores.

1.

As zephyr clock sources, SYSTICK timers are in use in both cores and timer clocking from external 32kHz XTAL oscillator.

Is this so ?

Should I specify  CONFIG_CLOCK_CONTROL_NRF_K32SRC_XTAL=y in prj.conf this line and for what core ?

2. RTCx timers is not used by default.

if I need to use those ( RTC0 on app core, RTC1 on net core), I should specify CONFIG_CLOCK_CONTROL_NRF_K32SRC_XTAL=y on both core's configuration ?

3. App core CPU clock is 128Mhz by default.

How to be sure if it clocked from XTAL oscillator ?

How to change clock to 64Mhz ?

4. Net core CPU clock is 64 Mhz by default.

How I be sure if it clocked from crystal oscillator ?

I can see clock_init() what use

clk_mgr = z_nrf_clock_control_get_onoff(CLOCK_CONTROL_NRF_SUBSYS_HF);
Should I use this code for app core as well or only on net core ?
On net core I use NRF_TIMER2 and RADIO and they need to be clocked form HF XTAL.
Regards,
Eugene

Parents
  • Hi,

    It's best to specify for each core what clock source they should run at. 

    The RTC is not a viable clock source for the Low Frequency Controller. 

    The documentation states:

    Each core has a number of low frequency clock (LFCLK) control instances. Each instance distributes one or more clocks to the core.

    The LFCLK control instance in each core distributes the 32.768 kHz PCLK32KI peripheral clock to its corresponding core. The LFCLK clock is sourced from the power and clock subsystem to each LFCLK control instance.

    In order to generate the LFCLK clock, the LFCLK controller uses the following LFCLK sources:
    32.768 kHz RC oscillator (LFRC)
    32.768 kHz crystal oscillator (LFXO)
    32.768 kHz synthesized from HFCLK (LFSYNT)

    The RTC will run off the LFCLK.

    When started, the RTC will automatically request the LFCLK source with RC oscillator if the LFCLK is not already running.

    You can check what clock source the LFCLK is running at by checking the LFCLKSTAT register.

    regards

    Jared 

  • Hi Jared !

    But what about HFLK XTAL. Should I do some enabling of it ?

    Some radio samples requiest it by _nrf_clock_control_get_onoff(CLOCK_CONTROL_NRF_SUBSYS_HF);

    other not.

    Regards,

    Eugene

  • Hi Eugene

    Once configured a PPI or DPPI channel will just operate in the background without needing any upkeep, refresh etc. 

    Even if the event register is not cleared, or you don't have interrupts enabled for certain events, they will still be available through the DPPI and trigger tasks whenever they occur. 

    If the channels don't appear to work it's typically caused by a configuration issue, by forgetting to enable the channels, or that the receiving peripheral gets the task at the wrong time (when it is not in a state to process that task for instance). 

    Is it intentional that you have two different events connected to the same capture register (CAPTURE1), and that you use the same compare register to trigger both TXEN and RXEN (COMPARE2) ?

    Best regards
    Torbjørn

  • Hi Torbjørn !

    Yes TX and RX is not enabled at the same time.

    I can see difference between nRF52 and nRF53 only in case that  DPPI channel need to be allocated from pool once and used after that.

    Channels should be usable all the time.

    TX/RX need to be enabled/disabled only when mode change from TX to RX and vise versa.

    Channels publish and subscribe can be reconfigured with the same values multiple times.

    If channel enabled, it should conduct event from source to target . (  Timer's event ISR can be enabled or not )

    All DPPI operations can be done in ISR context.

    If radio disabled for a while, no need to refresh public/subscribe pairs.

    When radio disabled, all DPPI channels are also disabled.

    But something else exist what do DPPI not working as expected.

    I need to write more simple radio for be sure if all pairs works as expected.

    Regards,

    Eugene

  • Hi Torbjørn !

    I found difference.

    It is not possible to specify beforehand pairs where the same subscribe is used ( even channel is different)

    Internally it make last subscribe active only. Even channels are disabled and freed every TX loop.

    nrf_radio_publish_set(NRF_RADIO, NRF_RADIO_EVENT_READY, ppi_radio_events_ready);
    nrf_timer_subscribe_set(NRF_TIMERX, NRF_TIMER_TASK_CAPTURE1, ppi_radio_events_ready);

    nrf_radio_publish_set(NRF_RADIO, NRF_RADIO_EVENT_ADDRESS, ppi_radio_events_address);
    nrf_timer_subscribe_set(NRF_TIMERX, NRF_TIMER_TASK_CAPTURE1, ppi_radio_events_address);

    nrf_radio_publish_set(NRF_RADIO, NRF_RADIO_EVENT_END, ppi_radio_events_end);
    nrf_timer_subscribe_set(NRF_TIMERX, NRF_TIMER_TASK_CAPTURE1, ppi_radio_events_end);

     I need to to do sequentially if would like to collect all events
    nrf_radio_publish_set(NRF_RADIO, NRF_RADIO_EVENT_READY, ppi_radio_events_ready);
    nrf_timer_subscribe_set(NRF_TIMERX, NRF_TIMER_TASK_CAPTURE1, ppi_radio_events_ready);
    enable
    Get interrupt for READY
    nrf_radio_publish_set(NRF_RADIO, NRF_RADIO_EVENT_ADDRESS, ppi_radio_events_address);
    nrf_timer_subscribe_set(NRF_TIMERX, NRF_TIMER_TASK_CAPTURE1, ppi_radio_events_address);
    enable
    Get interrupt for ADDRESS
    nrf_radio_publish_set(NRF_RADIO, NRF_RADIO_EVENT_END, ppi_radio_events_end);
    nrf_timer_subscribe_set(NRF_TIMERX, NRF_TIMER_TASK_CAPTURE1, ppi_radio_events_end);
    enable
    Get interrupt for END
    In this way it works.
    Have it sense for DPPI ?
    Regards,
    Eugene
  • Hi Eugene

    I am not quite sure I understand your problem, but can you confirm that you are constantly freeing and re-allocating channels? 

    This is not really how the DPPI is meant to be used. If you have a DPPI channel that you will use repeatedly for the same purpose you should not free it after you allocate it, if you do this then it makes sense that the driver might assign you a different channel ID and that all the existing configurations will stop working. 

    Instead you should simply disable the channel when you don't need it, and enable it afterwards. 

    Best regards
    Torbjørn

  • Hi Torbjørn !

    Yes I allocate channels numbers once and after that enable/disable/refresh public and subscribe pairs ( I write exactly the same values for refresh channel).

    In my case I would like to configure 3 channels for catch 3 radio events.

    READY, ADDRESS and END. After that I enable RX/TX(+shortcuts.)

    BUT

    I can't configure channels beforehand IF  all 3 channels expected to have end task as the same Timer capture

    nrf_timer_subscribe_set(NRF_TIMERX, NRF_TIMER_TASK_CAPTURE1, channel1);

    so even own channels are allocated and events is not happens at the same time, they can't execute capture task.

    And this is make difference with nRF52 MCU ( 3 pairs configured and enabled before TX/RX start).

    For overcome this limitation I configure (refresh values ) next pair in RADIO ISR when receive previous event.

    And it works as expected.

    Looks like channel, where pairs written the last a able to capture timer.

    And it not loosk as fork case e,g one to many. It is like many to one ?

    Can it be explained some how ?

    Regards,

    Eugene

Reply
  • Hi Torbjørn !

    Yes I allocate channels numbers once and after that enable/disable/refresh public and subscribe pairs ( I write exactly the same values for refresh channel).

    In my case I would like to configure 3 channels for catch 3 radio events.

    READY, ADDRESS and END. After that I enable RX/TX(+shortcuts.)

    BUT

    I can't configure channels beforehand IF  all 3 channels expected to have end task as the same Timer capture

    nrf_timer_subscribe_set(NRF_TIMERX, NRF_TIMER_TASK_CAPTURE1, channel1);

    so even own channels are allocated and events is not happens at the same time, they can't execute capture task.

    And this is make difference with nRF52 MCU ( 3 pairs configured and enabled before TX/RX start).

    For overcome this limitation I configure (refresh values ) next pair in RADIO ISR when receive previous event.

    And it works as expected.

    Looks like channel, where pairs written the last a able to capture timer.

    And it not loosk as fork case e,g one to many. It is like many to one ?

    Can it be explained some how ?

    Regards,

    Eugene

Children
  • Hi Eugene

    I expect the difference here is down to the difference between the PPI controller in the nRF52 series and the DPPI controller in the nRF53 series. 

    With the nRF52/PPI a single PPI channel can at most connect one event to two tasks (using the FORK endpoint for the second task). 

    With the nRF53/DPPI a single DPPI channel can connect a single event to as many tasks as you want, since there is no limit on how many tasks can subscribe to the same DPPI channel. 

    In order to connect one event to three tasks with the nRF52/PPI you need to use two distinct PPI channels, whereas on the nRF53 you can get away with one. 

    Does this explain the inconsistencies you are experiencing?

    Best regards
    Torbjørn

  • Hi Torbjørn !

    Yes and no.

    for initiate RX/TX I have

    if (is_tx) {
         NRF_TIMER_EVENT_COMPARE2 -> NRF_RADIO, NRF_RADIO_TASK_TXEN
    } else {
          NRF_TIMER_EVENT_COMPARE2  -> NRF_RADIO_TASK_RXEN
    }
    and it work as expected
    After that 

    I have 3( or 4) dedicated channels and connect 3 different events to one task

    NRF_RADIO_EVENT_READY -> NRF_TIMER_TASK_CAPTURE1
    NRF_RADIO_EVENT_ADDRESS -> NRF_TIMER_TASK_CAPTURE1
    NRF_RADIO_EVENT_END -> NRF_TIMER_TASK_CAPTURE1
    and coming soon
    NRF_RADIO_EVENT_ADDRESS -> NRF_CCM_TASK_CRYPT
    And this set of channels on nRF52 to be enabled before TX/RX start, work fine for nRF52
    But not on nRF53
    I have got conclusion that different events can't be linked to the same task ( capture1) like on nRF52.
    Only one channel conduct event.
    Can it be explained ? Why I can't configure and enable all 3 channels what should pass 3 different events to one task  ?
    If we drop forks and groups and able to reserve dedicated channel for each required pair, what kins od limitation we might have ?
    Regards,
    Eugene
  • Hi Eugene

    Thanks for the detailed description, now I understand the issue more clearly. 

    What you say is correct. The DPPI implementation in the nRF53 has a limitation that the PPI controller in the nRF52 doesn't have, and this is the fact that a task can only publish to one DPPI channel at a time, and an event can only subscribe to one DPPI channel at a time.  

    So while a single channel can have an unlimited number of subscriptions or publishers, a single subscriber or publisher can only connect to a single DPPI channel. 

    This does mean that there are certain PPI configurations that can not be properly duplicated using the DPPI controller. 

    In order to connect the READY, ADDRESS and END events of the radio to the CAPTURE1 task you need to use a single DPPI channel for this, which means you can't easily disable one or the other connections. 

    Do you have 2 free CC registers in the timer? 
    If so, would it be an alternative to use separate CC registers for READY, ADDRESS and END?

    Best regards
    Torbjørn

  • Hi Torbjorn !
    Thank you !
    This is explain behaviour what I have. Does it really written in DS or other document somewhere ?
    I will try to use different timers channel but I should rearrange code a bit.
    Could you point me to sample where 3 events are  attached to one channel /single task ?
    What I should do with other case :
    NRF_RADIO_EVENT_ADDRESS -> NRF_TIMER_TASK_CAPTURE1
    NRF_RADIO_EVENT_ADDRESS -> NRF_CCM_TASK_CRYPT
    It looks as simple fork but again the same event should force 2 tasks and ADDRESS can be part of group
    where 3 events force one task.
    How you handle those cases in your SoftDevices.
    Can EGU peripheral be used as proxy  in those cases and simplify these ?
    Regards,
    Eugene
  • Hi Eugene

    Hiihtaja said:
    This is explain behaviour what I have. Does it really written in DS or other document somewhere ?

    The difference between PPI and DPPI is not really documented. You would need to read the PPI and DPPI chapters in the respective product specifications and understand that there is an architectural difference between the two, even though they essentially do the same thing. 

    Hiihtaja said:
    Could you point me to sample where 3 events are  attached to one channel /single task ?

    All you have to do is have 3 events publish to the same DPPI channel. 

    Hiihtaja said:
    What I should do with other case :
    NRF_RADIO_EVENT_ADDRESS -> NRF_TIMER_TASK_CAPTURE1
    NRF_RADIO_EVENT_ADDRESS -> NRF_CCM_TASK_CRYPT

    i think your EGU proxy idea will work, yes. 

    Essentially you have to use one DPPI channel to connect RADIO_EVENT_ADDRESS to two distinct EGU TASKS, for instance EGU_TASK_TRIGGER[0] and EGU_TASK_TRIGGER[1].

    At this point you have basically converted the single ADDRESS event into two events (EGU_EVENT_TRIGGERED 0 and 1) which will both happen when the ADDRESS event occurs. 

    Then you can use two more DPPI channels to connect EGU_EVENT_TRIGGERED[0] to TIMER_TASK_CAPTURE1, and EGU_EVENT_TRIGGERED[1] to CCM_TASK_CRYPT. 

    These last two DPPI channels can then be assigned to groups, allowing you to enable and disable them easily. 

    Best regards
    Torbjørn

Related