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

TWI0 + TWI1 + SPIx

Hey Guys,

In my custom board I need to use two different I2C bus and one SPI.

At the moment i'm using twi_master to comunicate with one of the TWI bus, but to switch TWI the only option I've seen is to change:

TWI_MASTER_CONFIG_CLOCK_PIN_NUMBER (13U)

TWI_MASTER_CONFIG_DATA_PIN_NUMBER (14U)

how can i configure two istances of the twi_master?

Furthermore I need to use an SPI beside these the TWI, what SPI should I be using? Is it the SPI2 due to the concurrent use of TWI0 and TWI1?

I'm alittle bit confused.

Thanks.

Parents
  • To use two independent TWI instances, you probably need to implement your own twi master driver (it's easy, can be based on the original one). There are just few things to change like pins (obviously) and shorts that are used (not obvious for me at first :) ). Maybe something more, I don't remember. But like RK said, it is better to use one TWI instance to communicate with more devices - in my situation it was needed because of not expandable hardware design prototype.

    If you are using nRF51 and need both SPI and TWI, you have to stick to only one instance of TWI or switch between TWI/SPI during runtime.

Reply
  • To use two independent TWI instances, you probably need to implement your own twi master driver (it's easy, can be based on the original one). There are just few things to change like pins (obviously) and shorts that are used (not obvious for me at first :) ). Maybe something more, I don't remember. But like RK said, it is better to use one TWI instance to communicate with more devices - in my situation it was needed because of not expandable hardware design prototype.

    If you are using nRF51 and need both SPI and TWI, you have to stick to only one instance of TWI or switch between TWI/SPI during runtime.

Children
No Data
Related