Does Zephyr support PPI/SPIM communication?

Hello All,

 

I hope all is well. I have now been using Nordic ICs for close to 10 years and have become familiar with SDK5 and developed multiple applications using it. I am currently in the process of trying to learn the new Zephyr SDK for our new design and have made some nice progress. Where I am currently stuck is I need to use PPI to communicate with external peripherals and I am not sure which path I should go down on. From what I have been reading, it seems to me that in order to use PPI with SPIM, one must use the nrfx driver instead of the Zephyr. Here are few questions and concerns that I have:

 

  1. Is there a way to implement PPI/SPIM using the Zephyr SDK?
  2. If one must use the nrfx driver, what are the long-term repercussions? For example, I have read that if you one uses the nrfx driver, the power management unit(PMU) system will not know anything about the SPI instance and functions; and hence, it can not optimize power for it. If that is the case, doesn’t this almost render the use of PPI inadequate?
  3. I don't see any flags like NRFX_SPIM_FLAG_HOLD_XFER, and/or  NRFX_SPIM_FLAG_TX_POSTINC for PPI implementation. 
  4. Is there an example for the nRF52833 that shows how to implement PPI using Zephyr driver. there really needs to be more examples and documentations on this subject. any links and/or examples would be greatly appreciated.   

 

I have already coded my peripheral SPI communications using the Zephyr driver and now may have to restart from the beginning if PPI is not supported in the Zephyr SDK. These are some of the questions and concerns that I have. As always, your help is greatly appreciated and I look forward to all your responses.

 

Regards,

  • Also, what is the difference between DPPI and PPI. I did not see anything about this the ICs datasheet. again, thanks for the help.

    Regards,

  • Hello,

    Is there a way to implement PPI/SPIM using the Zephyr SDK?

    It is possible to do so. To include the nrfx SPIM drivers to your NCS project, you need to add the configuration:
    CONFIG_NRFX_SPIM=y.

    Similar to the way it was done in the nRF5 SDK, you set configs like these, which used to be found in sdk_config.h. Now they are defined in NCS\zephyr\hal_nordic\nrfx\Kconfig. So you also need to enable e.g. NRFX_SPIM0 in a similar fashion. 

    If one must use the nrfx driver, what are the long-term repercussions? For example, I have read that if you one uses the nrfx driver, the power management unit(PMU) system will not know anything about the SPI instance and functions; and hence, it can not optimize power for it. If that is the case, doesn’t this almost render the use of PPI inadequate?

    In general, the peripheral drivers in Zephyr are very generic, and they are written so that they work with a ton of different microcontrollers. In that way, they are very generic. It is correct that the PMU will not be aware of the SPIM when you are using the nrfx drivers directly, so you will have to handle the low power implementation yourself, like you did in the nRF5 SDK. The only long-term repercussions using the nrfx drivers is that it is not as straight forward to change the target device. If you only use Zephyr drivers, it is more or less a matter of config changes to change the target from an nRF52833 to another brand of microcontroller (as long as they are supported in Zephyr). When you are using the nrfx drivers directly, that transition is obviously not as simple anymore. Other than that, I would say that there are really no disadvantages.

    I don't see any flags like NRFX_SPIM_FLAG_HOLD_XFER, and/or  NRFX_SPIM_FLAG_TX_POSTINC for PPI implementation. 
    NRFX_SPIM_FLAG_HOLD_XFER is defined in nrfx_spim.h in Zephyr, as well as in the nRF5 SDK.
    Is there an example for the nRF52833 that shows how to implement PPI using Zephyr driver. there really needs to be more examples and documentations on this subject. any links and/or examples would be greatly appreciated. 

    Unfortunately, we don't have any dedicated samples for that. This is something that we are currently working on (expanding the sample portfolio). But the samples from the nRF5 SDK is a good starting point. The main change is that you don't enable it from sdk_config.h, but instead usnig CONFIG_... in your prj.conf file. 

    Wael said:
    Also, what is the difference between DPPI and PPI. I did not see anything about this the ICs datasheet. again, thanks for the help.

    The only difference is that PPI is for the nRF52 series, and the DPPI is for the nRF5340 (with multiple cores). So if you are using the nRF52833, you should use the PPI. 

    Best regards,

    Edvin

  • You may want to have a look at this guide:

     nRF Connect SDK Tutorial - Part 2 | NCS v1.2.0 

    Search for "I2C_NRFX" in that guide. Obviously, it uses I2C instead of SPI, but the method is the same.

    BR,

    Edvin

  • hi Edvin,

    thanks for taking the time to answer my questions. it seems that the Zephyr CONFIG_GPIO=n needs to be set. if so, does this mean all my GPIO pins need to be configured in the nrfx driver and not in the proj.conf? 

    Thanks

  • Wael said:
    it seems that the Zephyr CONFIG_GPIO=n

    That sounds strange. What did you base that conclusion on?

    BR,

    Edvin

  • Related