CONFIDENCE & CONFIG Settings

Each time I attempt to use a Zephyr API on my NORDIC device, I face the mystery of what CONFIG setting are required to go with it.  For example:

To make the Async UART API work, I consulted the Nordic's API page: docs.nordicsemi.com/.../group_uart_async.html

It doesn't mention any CONFIG settings.   After a GOOGLE search, I found a user that said these CONFIG settings are required:

#For UART
CONFIG_SERIAL=y
CONFIG_UART_ASYNC_API=y
CONFIG_UART_0_ASYNC=y
CONFIG_UART_0_NRF_HW_ASYNC=y
CONFIG_UART_0_NRF_HW_ASYNC_TIMER=2
CONFIG_NRFX_TIMER4=y
And sure enough, that made it work.   Out of curiosity, I commented out all but two of those, and it still seems to work.  I think?
#For UART
CONFIG_SERIAL=y
CONFIG_UART_ASYNC_API=y
#CONFIG_UART_0_ASYNC=y
#CONFIG_UART_0_NRF_HW_ASYNC=y
#CONFIG_UART_0_NRF_HW_ASYNC_TIMER=2
#CONFIG_NRFX_TIMER4=y
My point is that I'm "guessing" at CONFIG settings, hoping that they are correct.  That is not engineering. 
How can I take the guess work out of using Nordic with Zephyr when it comes to CONFIG settings?
Thank you

 

Parents
  • Hi,

     

    For the device that you use, which seems to be a nRF52832, that only has one UART instance, it will automatically select that instance if this is set:

    CONFIG_UART_ASYNC_API=y

    Then this is default y:

    CONFIG_UART_0_ASYNC=y

    However, these are not default y:

    CONFIG_UART_0_NRF_HW_ASYNC=y
    CONFIG_UART_0_NRF_HW_ASYNC_TIMER=2

    As the first one does not have a default 'y' in its definition:

    https://docs.nordicsemi.com/bundle/ncs-latest/page/kconfig/index.html#CONFIG_UART_0_NRF_HW_ASYNC

    Nor does the async timer instance:

    https://docs.nordicsemi.com/bundle/ncs-latest/page/kconfig/index.html#CONFIG_UART_0_NRF_HW_ASYNC_TIMER

     

    So, why is there multiple configurations here? The problem lies with the NRF_UARTE peripheral itself.

    https://docs.nordicsemi.com/bundle/ps_nrf52832/page/uarte.html#d955e183 

    It does not give you the "on-going" amount of bytes received directly in hardware (nRF54L-series gives this in the UARTE.RX.CURRENTAMOUNT register), so to be able to count the amount of bytes you're receiving, you need to use the byte-for-byte event RXDRDY.

     

    By looking at the configuration for the "_HW_ASYNC" feature, it uses dedicated hardware peripherals (PPI and TIMER instance) to count the incoming bytes as compared to using k_timer instance(s) for timeout.

    The UARTE hardware peripheral on nRF52832 will effectively be able to count each incoming byte with the RXDRDY event, and using a TIMER to count + PPI will be more efficient (and accurate) as compared to manually incrementing a byte-counter variable in a ISR.

     

    If you have a TIMER instance available, the best option is to enable:

    CONFIG_UART_0_NRF_HW_ASYNC=y
    CONFIG_UART_0_NRF_HW_ASYNC_TIMER=2

    I agree with your conclusion:

    My point is that I'm "guessing" at CONFIG settings, hoping that they are correct.  That is not engineering. 

    The choices that you are presented with are not explained properly, which I will bring up internally.

      

    Kind regards,

    Håkon

Reply
  • Hi,

     

    For the device that you use, which seems to be a nRF52832, that only has one UART instance, it will automatically select that instance if this is set:

    CONFIG_UART_ASYNC_API=y

    Then this is default y:

    CONFIG_UART_0_ASYNC=y

    However, these are not default y:

    CONFIG_UART_0_NRF_HW_ASYNC=y
    CONFIG_UART_0_NRF_HW_ASYNC_TIMER=2

    As the first one does not have a default 'y' in its definition:

    https://docs.nordicsemi.com/bundle/ncs-latest/page/kconfig/index.html#CONFIG_UART_0_NRF_HW_ASYNC

    Nor does the async timer instance:

    https://docs.nordicsemi.com/bundle/ncs-latest/page/kconfig/index.html#CONFIG_UART_0_NRF_HW_ASYNC_TIMER

     

    So, why is there multiple configurations here? The problem lies with the NRF_UARTE peripheral itself.

    https://docs.nordicsemi.com/bundle/ps_nrf52832/page/uarte.html#d955e183 

    It does not give you the "on-going" amount of bytes received directly in hardware (nRF54L-series gives this in the UARTE.RX.CURRENTAMOUNT register), so to be able to count the amount of bytes you're receiving, you need to use the byte-for-byte event RXDRDY.

     

    By looking at the configuration for the "_HW_ASYNC" feature, it uses dedicated hardware peripherals (PPI and TIMER instance) to count the incoming bytes as compared to using k_timer instance(s) for timeout.

    The UARTE hardware peripheral on nRF52832 will effectively be able to count each incoming byte with the RXDRDY event, and using a TIMER to count + PPI will be more efficient (and accurate) as compared to manually incrementing a byte-counter variable in a ISR.

     

    If you have a TIMER instance available, the best option is to enable:

    CONFIG_UART_0_NRF_HW_ASYNC=y
    CONFIG_UART_0_NRF_HW_ASYNC_TIMER=2

    I agree with your conclusion:

    My point is that I'm "guessing" at CONFIG settings, hoping that they are correct.  That is not engineering. 

    The choices that you are presented with are not explained properly, which I will bring up internally.

      

    Kind regards,

    Håkon

Children
Related