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

disabling twi/i2c

Hey, I am using twi_hw_master.c and twi_master.h libraries for twi and want to disable i2c to save power when not in use. I use the following two lines to disable the i2c:

NRF_TWI1->ENABLE       = TWI_ENABLE_ENABLE_Disabled << TWI_ENABLE_ENABLE_Pos; 

NRF_TWI1->POWER        = 0;

but it still works. What other steps do I need to take in order to disable the twi peripheral? I'm using nrf51822 on a custom board with sdk9.0. Thanks, Vandita

Code files: main.c latch_i2c.c

Parents
  • You'll have to set the following registers:

    NRF_TWI1->TASKS_STOP = 1;
    NRF_TWI1->ENABLE = TWI_ENABLE_ENABLE_Disabled << TWI_ENABLE_ENABLE_Pos;
    NRF_TWI1->INTENCLR = (TWI_INTENCLR_STOPPED_Disabled << TWI_INTENCLR_STOPPED_Pos)| \
                            (TWI_INTENCLR_RXDREADY_Disabled << TWI_INTENCLR_RXDREADY_Pos)| \
                            (TWI_INTENCLR_TXDSENT_Disabled << TWI_INTENCLR_TXDSENT_Pos)| \
                            (TWI_INTENCLR_ERROR_Disabled << TWI_INTENCLR_ERROR_Pos)| \
                            (TWI_INTENCLR_BB_Disabled << TWI_INTENCLR_BB_Pos);
    
  • This works to disable the i2c. Though the transfer function enables i2c if it is not enabled already which made it seem like i2c wasn't getting disabled. Issue was resolved.

Reply Children
No Data
Related