Lowest power mode on rak3172 using interrupt + timers

Hi,

I’m starting to use RAK3172 module for a battery powered application and this consumes ~7.7uA, far from the ~1,7uA claimed.

I’m using 2 GPIO pins with interrupts for external events and up to 3 timers (RAK_TIMER_0,1,2). GPIOs go to push buttons so doesn’t consume until pressed.

At setup end I have: api.system.lpm.set(1);
And in the loop: api.system.scheduler.task.destroy();

I have made some tests in order to lower the consumption with no success. I have removed the timers and the exact I have the same exact consumption.

Can anybody please guide me in how to reduce this figure? I’m using only the RUI3 api.

Thank you
Antonio

Welcome to the forum @AntonioPWNT

(1) 1.7uA is the MCU in low power mode, no application running, I never got a RAK3172 with a custom application down to that value
(2) Do the two GPIO’s for the interrupts have pull-ups or pull-down resistors? If yes, how many Ohm are the resistors.

Thankyou for your answer!

I’m using 3 GPIO with a push button

two have 10M resistor to GND
one have 10M resistor to VCC

just configured these PINs as INPUT (pinMode(GPIOxx, INPUT)).

Best regards
Antonio

That will not cause the additional 6uA you see.
I am guessing it is from the LoRa antenna RF switch + some other pull-ups/pull-downs that are inside the RAK3172 .

Agree.

I have just changed the pinMode INPUT to INPUT_PULLUP/PULLDOWN acordingly and saved an additional 0,5uA.

I was going to try and help but for some reason I cannot find the SX1262.c or SX126x.c files for RAK3172, only the headers? Is it opensource, where can I find it?

Anyways, for RAK11720 and RAK4630 (and I am assuming on the RAK3172) there was an issue and I had mentioned it to support. Basically here is what is happening: SX126xAntSwOn() and SX126xAntSwOff() functions are not being used. I changed my local build of RAK11720 so I am more efficient, I saw a 6uA current draw drop when the RADIO_ANT_SW is correctly toggled using the SX126xAntSwOn() and SX126xAntSwOff() functions.

2 Likes

Hi @beegee ,

can you please check what @brolly759 says?

Thank you
Antonio

ALready in our ToDo list. No ETA given.

2 Likes

I assume you have modified the mentioned SX1262.c files, right? And not simply called “SX126xANTSwOn or Off” in your code? I guess you’d need to have those c-files at hand to compile successfully.

This instructions are for the RAK11720:

In sx126x-board.c file the functions should be as follows:

void SX126xAntSwOn( void )
{
udrv_gpio_init(RADIO_ANT_SW, GPIO_DIR_OUT, GPIO_PULL_NONE, GPIO_LOGIC_HIGH);
}

void SX126xAntSwOff( void )
{
udrv_gpio_init(RADIO_ANT_SW, GPIO_DIR_OUT, GPIO_PULL_NONE, GPIO_LOGIC_LOW);
}

in that same file the SX126xWakeup function should be like this:

void SX126xWakeup( void )
{
    //CRITICAL_SECTION_BEGIN( );
    SX126xAntSwOn();
    GpioWrite( &SX126x.Spi.Nss, 0 );

    SpiInOut( &SX126x.Spi, RADIO_GET_STATUS );
    SpiInOut( &SX126x.Spi, 0x00 );

    GpioWrite( &SX126x.Spi.Nss, 1 );

    // Wait for chip to be ready.
    SX126xWaitOnBusy( );

    // Update operating mode context variable
    SX126xSetOperatingMode( MODE_STDBY_RC );

    //CRITICAL_SECTION_END( );
}

In sx126x.c

void SX126xCheckDeviceReady( void )
{
    if( ( SX126xGetOperatingMode( ) == MODE_SLEEP ) || ( SX126xGetOperatingMode( ) == MODE_RX_DC ) )
    {
        SX126xWakeup( );

        SX126xAntSwOn( );
    }
    SX126xWaitOnBusy( );
}

In sx126x.c as well:

void SX126xSetSleep( SleepParams_t sleepConfig )
{
    SX126xAntSwOff( );

    uint8_t value = ( ( ( uint8_t )sleepConfig.Fields.WarmStart << 2 ) |
                      ( ( uint8_t )sleepConfig.Fields.Reset << 1 ) |
                      ( ( uint8_t )sleepConfig.Fields.WakeUpRTC ) );
    SX126xWriteCommand( RADIO_SET_SLEEP, &value, 1 );
    SX126xSetOperatingMode( MODE_SLEEP );
}

I mentioned this bug to the team in May of this year, so who knows when it will get fixed. I dont know why, but I thought all the files are open source for the latest RUI3 versions? If we can get @beegee to tell us how to access the files: sx126x-board.c and sx126x.c files for RAK3172, then we should be good to do it ourselves. The above instructions might also fix the issue on RUI3 with RAK4630 as well.

A quick search in the mounted BSP folder of the RAK4630 shows that they are in the variants folder:

For the RAK3172 it is different, the functions are part of the STM32 core (because the LoRa transceiver is inside the STM32WLE5).

I found the sx126x.h, but there is no sx126x.c file. It might be in the SUBGHZ stuff which I can’t find.