SPI SCK draws current while in hibernate mode

Status
Not open for further replies.

EmielcpNL

Active member
Hi guys,

As mentioned before (in other topics) im using a teensy 3.2 with an SX1267 LoRa chip. Got everything working (almost) perfectly. Now I put it in hibernate (duff snooze library) mode and my device wakes up every 15minutes to send a massage. Teensy uses 50uA in hibernate mode, but the total device still uses 1.80mA.

After some testing I found out it's the clock of my SPI connection, when I disconnect the SCK (I use pin 13) + ground of the SX1276 the current drops to 50uA again. I tried cutting off the SPI before going to sleep but without succes. What have I done wrong :confused: Code I tried:

Code:
LMIC_shutdown();
  SPI.endTransaction();
  SPI.end(); // shutdown the SPI interface
  pinMode(13, INPUT);
  digitalWrite(13, LOW); // shut off pullup resistor
 
I am no expert on getting to lowest power, but you might try: pinMode(13, INPUT_DISABLE);

Although I don't think it will help, as I believe SPI.end(); Puts all of the IO pins into disabled state:
Code:
oid SPIClass::end()
{
	volatile uint32_t *reg;

	reg = portConfigRegister(hardware().mosi_pin[mosi_pin_index]);
	*reg = 0;
	reg = portConfigRegister(hardware().miso_pin[miso_pin_index]);
	*reg = 0;
	reg = portConfigRegister(hardware().sck_pin[sck_pin_index]);
	*reg = 0;
	port().MCR = SPI_MCR_MDIS | SPI_MCR_HALT | SPI_MCR_PCSIS(0x1F);
}

My guess is the issue is actually with the LoRa, and when you physically remove GND, it now longer has a complete circuit, so it does not use any current.
Again not sure which radio you are using, but it may have Pull ups on it, does it have it's own processor...
 
I am no expert on getting to lowest power, but you might try: pinMode(13, INPUT_DISABLE);

Although I don't think it will help, as I believe SPI.end(); Puts all of the IO pins into disabled state:
Code:
oid SPIClass::end()
{
	volatile uint32_t *reg;

	reg = portConfigRegister(hardware().mosi_pin[mosi_pin_index]);
	*reg = 0;
	reg = portConfigRegister(hardware().miso_pin[miso_pin_index]);
	*reg = 0;
	reg = portConfigRegister(hardware().sck_pin[sck_pin_index]);
	*reg = 0;
	port().MCR = SPI_MCR_MDIS | SPI_MCR_HALT | SPI_MCR_PCSIS(0x1F);
}

My guess is the issue is actually with the LoRa, and when you physically remove GND, it now longer has a complete circuit, so it does not use any current.
Again not sure which radio you are using, but it may have Pull ups on it, does it have it's own processor...

indeed, pinMode(13, INPUT_DISABLE) doesn't change anything. I understand what you mean, but it doesn't draw current when using an Arduino (and sleepmode). If it was the lora chip it would have done the same, right?
 
It is hard to say. Don't see the actual hardware? How is it hooked up in both cases. Likewise don't see the software, so not sure how much it is apple to apple....

For example: Is it the same LoRa hardware in both cases? The same pins hooked up?

What library? Is there code in place before you turn off SPI, where you tell the LoRa module to shut off? Maybe the library code for Teensy does not do the same thing when you try to disable it? Maybe there is an IO pin that can be used to enable/disable it?

Example suppose you are using adafruit RFM95 breakout: https://www.adafruit.com/product/3072
There is a pin labeled EN which the Adafruit document says:
connected to the enable pin of the regulator. Pulled high to Vin by default, pull low to completely cut power to the radio

Maybe in one of your hook ups you have this set? Maybe in the other you don't? Or maybe you should? Maybe hooked up to IO pin? Not sure if best to then simply set the IO pin to LOW, or to turn it off and have external PD resistor? I am not EE...

Hopefully someone else who has done some of this will chime in.

Good luck
 
Hello,

I had a simelar problem (but other external hardware) with current by SPI in hibernate for teensy3.2.
As KurtE told, my solution was pinMode(xx, INPUT_DISABLE) but for all SPI lines.
Then I achieved 0.3 mA in hibernate for t3.2, what ist okay because 0.250 mA is for LDO on teensy board in idle.
I also switched off all power for external hardware by MOSFET.

Worked for me.

Good luck.
 
pinMode(xx, INPUT_DISABLE) isn't working for me, I'm also switching off my sensors with a transistor. Everything works fine when I replace Snooze.hibernate for a simple delay. Sensors turn off, SPI or I2C doesn't draw any current. But whenever I use Snooze.hibernate, my sensors stay on and SPI draws current... :confused:
 
EDIT: Sorry really talking to myself right here xD But fixed it partly, now trying to fix SPI. I'm on 1.8mA in hibernate now, better than the 40mA I had first lol
 
Last edited:
@duff I tried your example. Added SPI SnoozeBlock and SX1276.spiClockPin(14);

Also tried :

Code:
SPI.end()
pinMode (xx, INPUT_DISABLE); (closed at SPI Pins

Also tried:

Code:
LMIC_shutdown();
 delay(50);
 SPI.endTransaction();
SPI.end();

I see it's going really low for half a second (like 0.10mA) but it goes back to 1.8mA in hibernate mode
 
Status
Not open for further replies.
Back
Top