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

nRF52840 as I2C slave (TWIS)

Hello Nordic,

I have a sparkfun nRF52840 mini and I want to know which project from nRF5_SDK_15.3.0_59ac345 should I use to have my nRF52840 slave in the TWI communcation?

I tried to modify 'twi_master_with_twis_slave', but it doesn't work. I don't know which are the correct pins, the correct TWIS address.

Can you give me an example or something helpful to be able to begin to write a correct code in order to configure TWIS?

Please be aware of the fact the the pins from sparkfun nRF52840 mini are different from nRf52840 DK.

Thank you.

Parents
  • Hello,

    Have you seen the SPI Slave example, from the SDK v15.3.0?
    It configures the device as an SPI slave. You can verify this by programming another device with the SPI Master(SPIM) example, also found in the SDK.
    The SPIS API Reference might also be useful to you.

    I tried to modify 'twi_master_with_twis_slave', but it doesn't work. I don't know which are the correct pins, the correct TWIS address.

    The pins are defined in the sdk_config.h file, if this is what you are asking. You would however need to see where each pin is accessible on your sparkfun mini.

    Please be aware of the fact the the pins from sparkfun nRF52840 mini are different from nRf52840 DK.

    You may change the pins as you would like, but keep in mind the recommended uses as described in the Pin Assignment part of the nRF52840 documentation.

    Is this what you were looking for?

    Best regards,
    Karl

  • Hello,

    Thank you for the answer. I've tried SPI slave project, but I think I get a reset because the led is blinking even if in the main function it's written nothing. I don't know why.

  • Hi,

    I am terribly sorry, but it seems I replied to your question about TWI with information about SPI instead. My mistake.
    We do not have any examples demonstrating the nRF52840 in a TWI Slave configuration directly.

    The TWIS API Reference can be seen here.
    What you will need to do to set it up as a TWI Slave is to first add the source files nrf_drv_twi, nrfx_twi, and nrfx_twis, to your project.
    Then you need to use the nrfx_twis_enable and nrfx_twis_init functions to configure the device as a TWI slave.
    The TWI address and all the other TWI parameters are set during initialization. Please see the TWIS API Reference for a description of required input to these functions. You could also have a look at the code for any of the TWI_* examples, to see how to use the TWI interface.

    I am sorry that my initial reply only contained information about SPIS, when you were asking for TWIS. I hope this did not cause you any frustration or confusion.

    Best regards,
    Karl

  • Hello,

    No, not at all. I was glad that you told me about SPI slave because when I saw that I can't manage to make TWI slave to work, i've tried with SPI slave. I want to concentrate now on SPI because you have an explicit example in SDK. Can you help me, please, to solve the led which is toggling even if my main function is empty?

    Thank you.

  • Hello,

    I am happy to hear that you think so!
    Absolutely, I will help you achieve this.
    First, could you tell me more about your setup? Which devices do you have(apart from the sparkfun nRF52840 mini)? Which device will be the SPI Master, and how are they connected?
    Is the other device running the SPI Master example? If so, the blinking you are seeing is correct, as described in the SPI Slave example documentation.

    BMG said:
    Can you help me, please, to solve the led which is toggling even if my main function is empty?

    Are you talking about the main function of the SPI Slave example? Have you made any modifications to the example?
    The led is supposed to toggle every time an SPI transfer completes. If you see the very last line of the main while-loop, you will see the function call to toggle the led.

    Best regards,
    Karl

     

Reply
  • Hello,

    I am happy to hear that you think so!
    Absolutely, I will help you achieve this.
    First, could you tell me more about your setup? Which devices do you have(apart from the sparkfun nRF52840 mini)? Which device will be the SPI Master, and how are they connected?
    Is the other device running the SPI Master example? If so, the blinking you are seeing is correct, as described in the SPI Slave example documentation.

    BMG said:
    Can you help me, please, to solve the led which is toggling even if my main function is empty?

    Are you talking about the main function of the SPI Slave example? Have you made any modifications to the example?
    The led is supposed to toggle every time an SPI transfer completes. If you see the very last line of the main while-loop, you will see the function call to toggle the led.

    Best regards,
    Karl

     

Children
No Data
Related