I am unable to get my UART to I2C dev module to go to sleep as it should, it appears that the chip will not go to sleep due to an interrupt condition that I am unable to clear, but that is my best guess after the investigation below. Everything I have tried to do to work with this chip works (i.e. reading UART data in via I2C), but it just won't go to sleep, always stays at ~4.8mA.
Current consumption is monitored via a Nordic PK2, where the 3.3Vout is going just to the module directly, bypassing the module's LDO.
Datasheet: https://www.nxp.com/docs/en/data-sheet/SC16IS740_750_760.pdf?
My "go to sleep" function:
void SC16IS750::enableSleep()
{
uint8_t temp_reg;
Serial.print("LCR(before): "); Serial.println(ReadRegister(SC16IS750_REG_LCR), HEX);
Serial.print("EFR(before): "); Serial.println(ReadRegister(SC16IS750_REG_EFR), HEX);
Serial.print("IER(before): "); Serial.println(ReadRegister(SC16IS750_REG_IER), HEX);
Serial.print("FIFO(before): "); Serial.println(ReadRegister(SC16IS750_REG_FCR), HEX);
Serial.print("IIR(before): "); Serial.println(ReadRegister(SC16IS750_REG_IIR), BIN);
Serial.println(); Serial.println("Changing values...");
uint8_t temp_lcr = ReadRegister(SC16IS750_REG_LCR); //set LCR to 0xBF to enable EFR
Serial.print("LCR(before): "); Serial.println(temp_reg, HEX);
WriteRegister(SC16IS750_REG_LCR, 0xBF);
temp_reg = ReadRegister(SC16IS750_REG_LCR);
Serial.print("LCR(after): "); Serial.println(temp_reg, HEX);
temp_reg = 0x00;
Serial.print("EFR(before): "); Serial.println(temp_reg, BIN);
bitSet(temp_reg, 4);
WriteRegister(SC16IS750_REG_EFR, temp_reg);
Serial.print("EFR(after): "); Serial.println(ReadRegister(SC16IS750_REG_EFR), BIN);
temp_reg = ReadRegister(SC16IS750_REG_IER);
Serial.print("IER(before): "); Serial.println(temp_reg, BIN);
bitSet(temp_reg, 4);
WriteRegister(SC16IS750_REG_IER, temp_reg);
Serial.print("IER(after): "); Serial.println(ReadRegister(SC16IS750_REG_IER), BIN);
Serial.println(); Serial.println("Values Changed");
delay(5000);
//check sleep mode allowance
//EFR[4]?
Serial.println(); Serial.println("Sleep allowed?(BIN)");
Serial.print("EFR[4]: (1 is good) "); Serial.println(bitRead(ReadRegister(SC16IS750_REG_EFR), 4));
//IER[4]?
Serial.print("IER[4]: (1 is good) "); Serial.println(bitRead(ReadRegister(SC16IS750_REG_IER), 4));
//FIFO cleared/enabled?
//FIFOEnable(0);
Serial.print("FIFO: (1 means enabled, 0 is good) "); Serial.println(bitRead(ReadRegister(SC16IS750_REG_FCR), 0));
//interrupt pending?
Serial.print("IIR: (should be 1)"); Serial.println(ReadRegister(SC16IS750_REG_IIR), BIN);
//shift register cleared?
Serial.println(); Serial.println("Value Printouts in HEX...");
Serial.print("LSR[5]: "); Serial.println(bitRead(ReadRegister(SC16IS750_REG_LSR), 5));
Serial.print("LSR[6]: "); Serial.println(bitRead(ReadRegister(SC16IS750_REG_LSR), 6));
Serial.print("LCR(after): "); Serial.println(ReadRegister(SC16IS750_REG_LCR), HEX);
Serial.print("EFR(after): "); Serial.println(ReadRegister(SC16IS750_REG_EFR), HEX);
Serial.print("IER(after): "); Serial.println(ReadRegister(SC16IS750_REG_IER), HEX);
Serial.print("FIFO(after): "); Serial.println(ReadRegister(SC16IS750_REG_FCR), HEX);
Serial.print("IIR(after): "); Serial.println(ReadRegister(SC16IS750_REG_IIR), HEX);
}
The serial output of running this function:
LCR(before): 3
EFR(before): 1
IER(before): 0
FIFO(before): 1
IIR(before): 1
Changing values...
LCR(before): 0
LCR(after): BF
EFR(before): 0
EFR(after): 10000
IER(before): 0
IER(after): 10000
Values Changed
Sleep allowed?(BIN)
EFR[4]: (1 is good) 1
IER[4]: (1 is good) 1
FIFO: (1 means enabled, 0 is good) 0
IIR: (should be 1)10000
Value Printouts in HEX...
LSR[5]: 0
LSR[6]: 0
LCR(after): BF
EFR(after): 10
IER(after): 10
FIFO(after): 10
IIR(after): 10
10000
PK2 output:
For the life of me, I cannot figure out why the IIR is returning a value!