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

how to toggle spim1 and twim1

I want to use nrf52832 to communicate with my sensors , but my three sensors should use spis to communicate, the others use TWI ,so in sampling , I need to switch between spi and twi, in the file nrf_drv_config.h when i use spi ,I should #define SPI0_ENABLED 1,change 0 to 1,when i use TWI ,I shoule change do like this ,too:#define TWI0_ENABLED 1. However,the twim1 and the spim1 is the same address, in my project ,when i use spi this time then the next time i should use TWI,i want to ask question is how to toggle spi or twi enable and diasble ?

Parents
  • I think what you need to do is to use TWI0 along with SPI1 or TWI1 along with SPI0. Would this solve your issue?

    As I know you cannot use TWI1 with SPI1 but you can use TWI0 with SPI1.

  • First of all, you cannot toggle the #define EXAMPLE commands because they are not commands for your program file, they are commands for the compiler. When the compiler is compiling your C code and turning it into a .hex file, it does not include those statements. So there is no way to toggle them while the program is running.

    If the peripherals have the same address I don't think you can use them. I am not really familiar with SPI but in TWI (i2c) you are not supposed to use two devices with the same 7-bit device_address at least that is what I am told. If you are using multiple EEPROMs for instance, they have additional address bits just for you to configure and differentiate its 7-bit address from other same type EEPROMs.

    I don't know if this was helpful at all. Maybe if you can explain which peripherals you are using I can help more.

Reply
  • First of all, you cannot toggle the #define EXAMPLE commands because they are not commands for your program file, they are commands for the compiler. When the compiler is compiling your C code and turning it into a .hex file, it does not include those statements. So there is no way to toggle them while the program is running.

    If the peripherals have the same address I don't think you can use them. I am not really familiar with SPI but in TWI (i2c) you are not supposed to use two devices with the same 7-bit device_address at least that is what I am told. If you are using multiple EEPROMs for instance, they have additional address bits just for you to configure and differentiate its 7-bit address from other same type EEPROMs.

    I don't know if this was helpful at all. Maybe if you can explain which peripherals you are using I can help more.

Children
No Data
Related