This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

I2C and software low power optimization

Hi there,

One question about how to save power with software optimization with a I2C data communication. In my mind, the key concept is to deal with interrupts. 

In a read operation in the body of my code there the following lines :

while(data_read == 0){
    UCB0CTL1 |= UCTXSTT;
    UCB0TXBUF = 0x00;
    UCB0CTL1 |= UCTXSTP;
    __delay_cycles(200);
    data_read = UCB0RXBUF;
}

I ask me the opportunity to programming that with interrupt with USCIAB0TX_VECTOR to send my data. But three question :

- May really same energy with an interrupt to send data in that part ? 

- Is-there a mean to adapt that with USCIAB0TX_VECTOR and enable RX interrupt ?

Thanks for your reply.

BR

GM

  • Gege said:
    - May really same energy with an interrupt to send data in that part ? 

    Depends on CPU clock speed and I2C clock speed.

    If you have a delay of 200 MCLK cycles, thsi uses a certain amount of energy. If you have an ISR isntead, you sleep for those 200 cycles (or more or less, depending on actual I2C speed) Which isn't long. Now the ISR adds some clock cycles (11 at least) to the execution, so you only save 189 o rless. It will still amke some difference, but I 'm not sure whether it is worth the effort.

    More important is theat your code won't handle if the slave doesn't respond. It will simply lock.

    oh, and when reading I2C, writing to TXBUF is void. But it adds a short delay of a few MCLK cycles before you set TXSTP, which might be required.

**Attention** This is a public forum