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

Interrupts in Application with LIS2DH12, TWI, and BLE

Hi everyone,

I am using a chip nRF52832 reading data from LIS2DH12 via TWI (all in a custome boad), then data will be send to Master nRF52832 DK ia BLE_NUS. However, when I use the interrupt pin in LIS2DH12, BLE will stop advertising. When I turn off the interrupt in LIS2DH12, BLE advertises but the sample_rate in LIS2DH12 will be set very low (50Hz,... etc). I had read about the interrupt priority but I cannot find anything. I think maybe there is problem in memory area assigning for the application. 

Can you guys please give me some hints to solve this problem? Any suggestion will be appreciated. 

Thanks in advance.

Milo

Parents
  • Hi,

    You should not have any problems using both BLE and TWI. Do you do a lot of time consuming stuff in the TWI event handler? All event handlers are running in interrupt context, so that could be a problem. What is the interrupt priority of TWI in your application? That is typically set by TWI_DEFAULT_CONFIG_IRQ_PRIORITY in your projects sdk_config.h or perhaps possibly set directly by setting the interrupt_priority field in the nrf_drv_twi_config_t instance you pass to nrf_drv_twi_init() (depending on your application).

Reply
  • Hi,

    You should not have any problems using both BLE and TWI. Do you do a lot of time consuming stuff in the TWI event handler? All event handlers are running in interrupt context, so that could be a problem. What is the interrupt priority of TWI in your application? That is typically set by TWI_DEFAULT_CONFIG_IRQ_PRIORITY in your projects sdk_config.h or perhaps possibly set directly by setting the interrupt_priority field in the nrf_drv_twi_config_t instance you pass to nrf_drv_twi_init() (depending on your application).

Children
  • Thanks for your reply. Sorry for my late response.

    In the nrf_drv_twi_config_t instance, I config TWI_DEFAULT_CONFIG_IRQ_PRIORITY = 2 and the TWI_DEFAULT_CONFIG_IRQ_PRIORITY in your projects sdk_config.h is 7. 

    In the TWI event handler, I  use NRF_DRV_TWI_XFER_TX and NRF_DRV_TWI_XFER_RX with 2 flags notifying the transfer done. 

    I have tried to change the priority. The application still stops in interrupt of LIS2DH12. If the priority is 2, application can work without the interrupt of LIS2DH12.

    The interrupt in LIS2DH12 is configuring an IO pin as a positive edge triggered interrupt source in order to send data from sensor to microcontroller. In addiiton, the priority of GPIOTE = 2.

    Do you have any other suggestions for me?

    Thanks.

  • Hi,

    It is difficult to say anything specific without seeing your code. Can you upload it?

    Without knowing more, it would be tempting to think that you wait for something that does not happen for some reason. For instance, it could be that you wait for a variable to change state in a event handler that should be set in another, and this is not volatile. Or that an event handler spends too much time doing some other stuff for some reason.

  • Hello,

    Yep. I will upload the code in a private ticket.

    Thanks so much for your help.

Related