Enable 4 SPI instances in nrf52840

Hi,

I am using nrf52840. we have already used 3 SPI instance (SPIM1, SPIM 2, SPIM 3). wanted to use one more SPI instance i.e. SPIM 0. but if I enable this I am getting                                                                                                                                                                                                                                                                                                                                                             " 'NRF_DRV_SPI_INSTANCE_SPI_INSTANCE_0' undeclared here (not in a function)" this error. 

can you please help us to solve this issue.

Thank you,

Shreya 

Parents
  • Hello Shreya,

    Thanks for sharing the update. I am glad that you have found the root cause.

    Now it makes sense why this 'NRF_DRV_SPI_INSTANCE_SPI_INSTANCE_0' undeclared here'' error. SPI and TWI peripherals can operate simultaneously. But it should not share the same instance IDs (same registers or resources). 

    When using a peripheral that share an ID, we need to disable the previously used peripheral, remove any PPI connections set up for the peripheral that is being disabled, clear all bits in the INTEN register, explicitly configure the peripheral that we enable and should not rely on configuration values that may be inherited from the peripheral that was disabled, and then enable the now configured peripheral.

Reply
  • Hello Shreya,

    Thanks for sharing the update. I am glad that you have found the root cause.

    Now it makes sense why this 'NRF_DRV_SPI_INSTANCE_SPI_INSTANCE_0' undeclared here'' error. SPI and TWI peripherals can operate simultaneously. But it should not share the same instance IDs (same registers or resources). 

    When using a peripheral that share an ID, we need to disable the previously used peripheral, remove any PPI connections set up for the peripheral that is being disabled, clear all bits in the INTEN register, explicitly configure the peripheral that we enable and should not rely on configuration values that may be inherited from the peripheral that was disabled, and then enable the now configured peripheral.

Children
No Data
Related