Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 9 of 9

Thread: SPI SCK draws current while in hibernate mode

  1. #1

    SPI SCK draws current while in hibernate mode

    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 Code I tried:

    Code:
    LMIC_shutdown();
      SPI.endTransaction();
      SPI.end(); // shutdown the SPI interface
      pinMode(13, INPUT);
      digitalWrite(13, LOW); // shut off pullup resistor

  2. #2
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    5,053
    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...

  3. #3
    Quote Originally Posted by KurtE View Post
    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?

  4. #4
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    5,053
    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

  5. #5
    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.

  6. #6
    Senior Member duff's Avatar
    Join Date
    Jan 2013
    Location
    Las Vegas
    Posts
    961
    Look at the example Low_power_push_Button_Hold_SD_Logger.

  7. #7
    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...

  8. #8
    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 by EmielcpNL; 08-08-2019 at 01:21 PM.

  9. #9
    @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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •