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

[nrf51-dk] Can I use both twi instances as well as an SPI instance?

I have a project where I need both TWI instances as well as an SPI instance to be used with sdcard and fatfs libraries. When I try to compile I get the error: SPI1_TWI1_IRQHandler if I have SPI1_ENABLED or SPI0_TWI0_IRQHandler if I have SPI0_ENABLED. Note that this happens if I have TWI0_ENABLED and TWI1_ENABLED. If, for example, I have only TWI0_ENABLED and SPI1_ENABLED it compiles.

Note that I use TWI and SPI as master.

  • Hi,

    In the instantiation table in the nRF51 Reference Manual you can see that the TWI0 and SPI0 instance share the same base address/ID, and that TWI1 and SPI1 have the same base address/ID. That means that you cannot use both TWI instances + a SPI instance simultaneously on the nRF51, if you need that you will need to upgrade to nRF52832.

    But, if you enable PERIPHERAL_RESOURCE_SHARING_ENABLED, you can switch between using one of them (uninitialize one of them/ initialize the other). E.g. you can disable SPI1, enable TWI1, and when you are finished using TWI1 you can disable it and enable the SPI1 again.

    nRF51 instantiation table: image description

Related