Other Parts Discussed in Thread: TPS8802
Tool/software:
Hello TI Team,
I’m referring to the Sleep Mode functionality described in Section 8.4.1 Sleep Mode of the TPS8802 AFE datasheet [Page 40].
I have configured the TPS8802 to transition from Sleep mode (SLEEP_EN = 1
) to Wake-up mode (SLEEP_DONE / SLEEP_EN = 0
) using a timer-based approach.
In this setup, I’ve set the sleep timer to 10 seconds. This means the TPS8802 enters Sleep mode (indicated by STATUS1
register showing VCCLOW
) for 10 seconds before automatically waking up (indicated by STATUS1
showing SLP_DONE
).
The MCU continuously monitors the STATUS1
register to detect the transition from sleep to wake-up.
At boot-up, the MCU calls the function afe_i2c_sleep_timer(10000)
to configure the sleep timer for 10 seconds (10000 ms), using the appropriate I2C register settings as specified in the TPS8802 datasheet.
Once the timer is initiated, the MCU repeatedly calls CheckSleepTimeExpiry()
to read the STATUS1
register and monitor the sleep-to-wake status.
Please refer to the code snippet below:
void CheckSleepTimeExpiry() { static uint32_t elapsed_time = 0; int ret = 0; elapsed_time += 1000; // Assuming this function is called every 1 second (1000 ms) ret = afe_i2c_status_read_reg(TPS880X_REG_STATUS1); if(ret == SLP_DONE) { i2c_write_data(i2c_dev, TPS880X_REG_ENABLE2, 0x84); //SLP_EN = 0 StopI2CSleepTimer(); } else if (elapsed_time >= SetSleeptime+5) { i2c_write_data(i2c_dev, TPS880X_REG_ENABLE2, 0x84); //SLP_EN = 0 StopI2CSleepTimer(); elapsed_time = 0; // Reset the elapsed time printk("Abort Timer.\n"); } printk("Elapsed time: %u ms\n", elapsed_time); } void afe_i2c_sleep_timer(uint16_t sleep_time) { SetSleeptime = sleep_time; // Mask all interrupts, enable INT_MCU i2c_write_data(i2c_dev, TPS880X_REG_MASK, 0xFF); i2c_write_data(i2c_dev, TPS880X_REG_CONFIG1, 0x37); //SLP_MCU = SLP_ANALOG = SLP_BST = 1 i2c_write_data(i2c_dev, TPS880X_REG_ENABLE1, 0x3D); // INT_EN = 1 i2c_write_data(i2c_dev, TPS880X_REG_ENABLE2, 0x85); // SLP_EN = LEDPIN_EN = INT_DIR = LEDSEL = 1 if (sleep_time == 0) { // Disable the Sleep timer i2c_write_data(i2c_dev, TPS880X_REG_SLPTMR1, 0x00); i2c_write_data(i2c_dev, TPS880X_REG_SLPTMR2, 0x00); } else { // Validate interval if (sleep_time < DUALRAYSMOKEAFE_HAL_TIMING_ULPTIMER_MIN_INTERVAL_MS) { sleep_time = DUALRAYSMOKEAFE_HAL_TIMING_ULPTIMER_MIN_INTERVAL_MS; } else if (sleep_time > DUALRAYSMOKEAFE_HAL_TIMING_ULPTIMER_MAX_INTERVAL_MS) { sleep_time = DUALRAYSMOKEAFE_HAL_TIMING_ULPTIMER_MAX_INTERVAL_MS; } } // MSB i2c_write_data(i2c_dev, TPS880X_REG_SLPTMR1, sleep_time >> 8); // LSB i2c_write_data(i2c_dev, TPS880X_REG_SLPTMR2, sleep_time & 0xFF); k_timer_init(&si2cSleepTimer, &SleepTimerHandler, nullptr); k_timer_user_data_set(&si2cSleepTimer, nullptr); StartSleepTimerHandler(); } uint8_t afe_i2c_status_read_reg(uint8_t reg_addr) { int ret = 0; uint8_t status = 0; uint8_t status_val = 0; ret = i2c_reg_read_byte(i2c_dev, AFE_ADDR, reg_addr, &status); if (ret != 0) { printk("Failed to read Status register\n"); } printk("Status Value: %d\n", status); if (reg_addr == TPS880X_REG_STATUS1){ if (status & VCCLOW) { printk("VCCLOW\n"); status_val = VCCLOW; } if (status & MCULDO_ERR) { printk("MCULDO_ERR\n"); status_val = MCULDO_ERR; } if (status & OTS_ERR) { printk("OTS_ERR\n"); status_val = OTS_ERR; } if (status & OTS_WRN) { printk("OTS_WRN\n"); status_val = OTS_WRN; } if (status & BST_NACT) { printk("BST_NACT\n"); status_val = BST_NACT; } if (status & BST_ERR) { printk("BST_ERR\n"); status_val = BST_ERR; } if (status & INT_UNIT) { printk("INT_UNIT\n"); status_val = INT_UNIT; } if (status & SLP_DONE) { printk("SLP_DONE\n"); status_val = SLP_DONE; } } return status_val; }
Based on the previously provided code, the timer-based sleep-to-wake functionality is working as expected.
Q1: How can I configure the TPS8802 to wake up the MCU using TPS8802 interrupt pin (INT_MCU / GPIO)?
In the current implementation, I enabled the interrupt by writing to the I2C register as follows:
i2c_write_data(i2c_dev, TPS880X_REG_ENABLE1, 0x3D); // INT_EN = 1 (as per datasheet)
Interrupt Pin Connection:
TPS8802 (INT_MCU / GPIO) ----> MCU (GPIO Pin)
However, when I try to read the INT_MCU / GPIO
on the corresponding GPIO pin of the MCU, I do not receive any status change on MCU GPIO while tps8802 is going to sleep/wakeup.
Could you please guide me on the correct configuration or additional steps required to trigger and read the interrupt signal from TPS8802 to the MCU?
Q2: How can I wake up the TPS8802 using an MCU GPIO pin (from low to high transition)?
I would also like to configure the setup in the opposite direction, where the MCU can wake up the TPS8802 using one of the MCU GPIO pins by toggling it from LOW to HIGH.
Please advise on the correct register settings or hardware configuration needed to support this functionality.
Thanks & Regards,
Pratik Panchal