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

TWI0 and SPI0 time multiplex

Hi there,

Is it possible to use TWI0 and SPI0 (or TWI1/SPI1) time multiplexed?

When enabling them both in sdk_config.h I get "Error: L6200E... IRQHandler multiply defined...", which can be resolved by defining PERIPHERAL_RESOURCE_SHARING_ENABLED. Is there any documentation available to find out exactly whats going on under the hood and what to be aware of?

Many thanks, Josef

Parents
  • You cannot use serveral peripheral instances that share the same IDs/base addresses at the same time, so if you want to use TWI and SPI at the same time, you should use e.g. TWI0 and SPI1. Here is the table of which IDs/base address the different peripheral instances use.

    What the peripheral resource sharing(PERIPHERAL_RESOURCE_SHARING_ENABLED) enables you to do is to first use e.g. TWI0, then you have to uninitialized it, and then you can use SPI0. Normally, this is not possible, because interrupt handlers are implemented in individual drivers. This functionality requires a more complicated interrupt handling and driver initialization, hence it is not always desirable to use it. The functionality was just recently added(SDK11), and there is not much documentation on it yet. If you want to take a look "under the hood", you can find the implementation in nrf_drv_common.c. The implementation is basically a kind of mutex, that will return NRF_ERROR_BUSY if you try to initialize several peripheral instances that use the same ID/Base Address.

Reply
  • You cannot use serveral peripheral instances that share the same IDs/base addresses at the same time, so if you want to use TWI and SPI at the same time, you should use e.g. TWI0 and SPI1. Here is the table of which IDs/base address the different peripheral instances use.

    What the peripheral resource sharing(PERIPHERAL_RESOURCE_SHARING_ENABLED) enables you to do is to first use e.g. TWI0, then you have to uninitialized it, and then you can use SPI0. Normally, this is not possible, because interrupt handlers are implemented in individual drivers. This functionality requires a more complicated interrupt handling and driver initialization, hence it is not always desirable to use it. The functionality was just recently added(SDK11), and there is not much documentation on it yet. If you want to take a look "under the hood", you can find the implementation in nrf_drv_common.c. The implementation is basically a kind of mutex, that will return NRF_ERROR_BUSY if you try to initialize several peripheral instances that use the same ID/Base Address.

Children
Related