This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how to integrate twi code with another spi code

Hi,

I having an nrf52832 board and using gnu arm, nrfjprog to program the device. i reading data from two different sensors using spi and TWI in two different codes. now i need to combine the two project to one, so i tried to add the twi to the spi code but some error as shown below comes up. i have edited the makefile and sdk config files but not sure weather its correctly done.image description

I am editing the makefile and sdk line by line, is there any other way to do this ? something like a gui. i have attached the make fileMakefile and sdk filesdk_config.h(/attachment/f48c8b3e3463ecf6b44cd77adb15caa2)

  • Many commercial GUI's are available that you could use, e.g. Keil, IAR and Segger Embedded Studio. But I think the cheapest of these is Segger Embedded Studio and the cost is around $1000 USD for a commercial license (rather than a demo license). Keil and IAR are much more expensive

    I doubt if any of the commercial GUI / Toolchains would tell you where the problem is.

    Segger Embedded Studio is just a wrapper for GCC. Keil and IAR both use their own compilers so will give a different output, but it would basically tell you the same thing.

    i.e you have a multiple definition of

    SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler

    You should look in your code for this function, as you have defined it twice, or somehow included implementations of it twice

    Then probably change your code so that the same function in the two differences has different names, and adjust your setup code accordingly to use the new function names.

    BTW. This is development 101, its not specific to the Nordic products / SDK / API or toolchain

  • SPI and TWI are shared resources. You cannot use SPI0 at the same time with twi0. You can use spi0 and twi1 or vice versa.

  • @madblue: This is stated in the Memory section of the nRF52832 Product Specification, here is the link. You will need to change either

    #define SPI_INSTANCE  0 /**< SPI instance index. */
    static const nrf_drv_spi_t spi = NRF_DRV_SPI_INSTANCE(SPI_INSTANCE);
    

    or

    #define TWI_INSTANCE_ID     0
    static const nrf_drv_twi_t m_twi = NRF_DRV_TWI_INSTANCE(TWI_INSTANCE_ID);
    

    in your code to use another instance, e.g. TWI_INSTANCE_ID 1 in addition to enabling this in the sdk_config.h file.

  • Thank you so much Nguyen Hoan Hoang, it did solve my issue.

  • thank you Roger Clark, the informations you have shared is very helpful and appreciate it very much :)

Related