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

TWI with Softdevice Enabled

So there seems to be a conflict between the TWI and the Softdevice. My I2C communication works over TWI fine in isolation but when i try to send data over ble the TWI doesnt seem to do anything. Are there any examples that use both? Maybe a procedure for initialization orders and wait times for things to work well?

Much Thanks

Parents
  • There isn't anything special about TWI so no special precautions are needed when using TWI with the softdevice apart from the regular ones.

    What is most often the problem however is the fact that the TWI module in the SDK uses the PPI, since the TWI shortcuts in the first nRF51822 were not functional. The PPI is protected when the softdevice is enabled, and hence must be accessed through the softdevice API, i.e. sd_ppi_*. If you don't do this, you end up in the HardFault handler.

    If this is the problem you're having (you should be able to easily see this by using the debugger), you can fix it by replacing all manipulation of the PPI with the softdevice functions instead. Remember that these APIs are available only when the softdevice is enabled.

    Edit: It should also be noted that if you have a second revision chip (chip revision FA or later), you can choose to use the shortcuts instead. The PPI was originally used in the TWI module since the SHORTS register was not functional on the first revision (see item 36 in the PAN), but this has been fixed in the second revision.

Reply
  • There isn't anything special about TWI so no special precautions are needed when using TWI with the softdevice apart from the regular ones.

    What is most often the problem however is the fact that the TWI module in the SDK uses the PPI, since the TWI shortcuts in the first nRF51822 were not functional. The PPI is protected when the softdevice is enabled, and hence must be accessed through the softdevice API, i.e. sd_ppi_*. If you don't do this, you end up in the HardFault handler.

    If this is the problem you're having (you should be able to easily see this by using the debugger), you can fix it by replacing all manipulation of the PPI with the softdevice functions instead. Remember that these APIs are available only when the softdevice is enabled.

    Edit: It should also be noted that if you have a second revision chip (chip revision FA or later), you can choose to use the shortcuts instead. The PPI was originally used in the TWI module since the SHORTS register was not functional on the first revision (see item 36 in the PAN), but this has been fixed in the second revision.

Children
Related