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

How to wakeup from I2C CLK?

Hello,

I am currently using the TWIS (slave!) peripheral to get data from a I2C master. Now I would like the ability to place the nRF52 in deep sleep mode with sd_power_system_off() until the master tries to communicate over I2C. Is it possible to use the I2C-CLK signal to wake up the nRF52? If so, how could I do it?

Thanks in advance for your help.

  • No it's not possible to directly use the I2C CLK signal to wake from power off. You can however disconnect the I2C peripheral before you sleep and use the GPIO line you're using for a clock to wake the system from sleep. After sleep you need to re-init everything anyway, including setting up the I2C peripheral. However you're not going to wake in time to read the incoming I2C transaction, you'll have long-since missed it. So unless your master is set up to wait a little and retry operations, that's not going to help you.

    Better to have a proper handshake on a GPIO pin which wakes the system and signals it's ready.

  • Hello,

    OK, I will try to disable the I2C peripheral and use the pin as a normal GPIO wake up. I can't add additional line for wake up, but I can make in sort that the master initiates a dummy read request in order to wake up and wait until the nRF52 has initialized the I2C slave.

    I will try to use the bsp_wakeup_buttons_set() function as example to wakeup from GPIO pin state change.

    For disconnecting the peripheral, is nrf_drv_twis_disable() enough or shall I also call nrf_drv_twis_uninit()?

  • Don't know - take a look at the code - since you are putting the system into system off mode as long as the peripheral is disabled enough to let go of the pins should work. When the chip goes off, that happens anyway so it's quite possible you don't have to do anything except turn off.

  • If you have enough IO pins you can connect one of them to I2C clock, use it to wake up and don't bother disable I2C, just make sure all pending events from that IO cleared. As for delay and dummy read, shell master use ACK anyway to make sure it talks to peripheral which exists or ready? In that case standard error handling/retry process should be applied.

  • Thanks Alex and RK for your ideas. Very helpfull

Related