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

Same pin selected in PSEL registers in multiple peripherals

We're writing code that does dynamic pin assignment which may change over time. This question is about how the crossbar deals with conflicting pin settings.

If I set the same pin in the PSEL registers for two different peripherals (e.g. first SPI0 and then TWI0), does the crossbar end up connecting that pin to both peripherals, or does it disconnect it from the first peripheral and connect it to the second on the second PSEL setting?

Naturally I don't want the pin connected to both peripherals; I just want to know if I need to clear the old PSEL pin assignment before setting the new one, or whether it's cleared automatically. Thanks!

Parents
  • Hi,

    If multiple peripherals are configured to the same pins, then the last peripheral that is enabled will internally claim/takeover the pins. You don’t need to clear the peripherals PSEL register, but you should properly uninitialize the previous peripheral before you enable the new one, i.e. disable IRQs, disable interrupts, wait for previous transfers to finish, and at last set the ENABLE register field to disabled. If you are using our drivers, then this is done for you by the uninit functions(e.g. nrf_drv_spi_uninit()).

    Note that SPIM0 and TWIM0 have the same ID/base addresses(see the instantiation table here). See also this post for some more info about that.

    Best regards,

    Sigurd

Reply
  • Hi,

    If multiple peripherals are configured to the same pins, then the last peripheral that is enabled will internally claim/takeover the pins. You don’t need to clear the peripherals PSEL register, but you should properly uninitialize the previous peripheral before you enable the new one, i.e. disable IRQs, disable interrupts, wait for previous transfers to finish, and at last set the ENABLE register field to disabled. If you are using our drivers, then this is done for you by the uninit functions(e.g. nrf_drv_spi_uninit()).

    Note that SPIM0 and TWIM0 have the same ID/base addresses(see the instantiation table here). See also this post for some more info about that.

    Best regards,

    Sigurd

Children
Related