Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SX1276.c RxTimeoutSyncWord timer is not stopped in SX1276SetSleep() #753

Closed
iotfreaks opened this issue Jun 19, 2019 · 1 comment
Closed

Comments

@iotfreaks
Copy link

Hi, when using sx1276 in FSK mode and calling Radio.Sleep() function it stops two timers:

void SX1276SetSleep( void )
{
    TimerStop( &RxTimeoutTimer );
    TimerStop( &TxTimeoutTimer );

    SX1276SetOpMode( RF_OPMODE_SLEEP );

    // Disable TCXO radio is in SLEEP mode
    SX1276SetBoardTcxo( false );

    SX1276.Settings.State = RF_IDLE;
}

But not RxTimeoutSyncWord timer.

In case if radio was in receiving mode before sleep, and we start anoter transmission before RxTimeoutSyncWord exceeds by calling Radio.Send(), we have unwanted interrupt SX1276OnTimeoutIrq(). This interrupt is caused by not stopped RxTimeoutSyncWord timer. The code inside Irq handler fully reset the chip:

    case RF_TX_RUNNING:
        // Tx timeout shouldn't happen.
        // But it has been observed that when it happens it is a result of a corrupted SPI transfer
        // it depends on the platform design.
        //
        // The workaround is to put the radio in a known state. Thus, we re-initialize it.

        // BEGIN WORKAROUND

        // Reset the radio
        SX1276Reset( );

        // Calibrate Rx chain
        RxChainCalibration( );

        // Initialize radio default values
        SX1276SetOpMode( RF_OPMODE_SLEEP );

        for( uint8_t i = 0; i < sizeof( RadioRegsInit ) / sizeof( RadioRegisters_t ); i++ )
        {
            SX1276SetModem( RadioRegsInit[i].Modem );
            SX1276Write( RadioRegsInit[i].Addr, RadioRegsInit[i].Value );
        }
        SX1276SetModem( MODEM_FSK );

        // Restore previous network type setting.
        SX1276SetPublicNetwork( SX1276.Settings.LoRa.PublicNetwork );
        // END WORKAROUND

This code solve the problem:

void SX1276SetSleep( void )
{
    TimerStop( &RxTimeoutTimer );
    TimerStop( &TxTimeoutTimer );
    TimerStop( &RxTimeoutSyncWord );  /*---Added---*/

    SX1276SetOpMode( RF_OPMODE_SLEEP );

    // Disable TCXO radio is in SLEEP mode
    SX1276SetBoardTcxo( false );

    SX1276.Settings.State = RF_IDLE;
}
@mluis1 mluis1 added this to the Release Version 4.4.2 milestone Jul 2, 2019
@mluis1
Copy link
Contributor

mluis1 commented Jul 2, 2019

Thanks for the proposition.

mluis1 added a commit that referenced this issue Jul 2, 2019
@mluis1 mluis1 closed this as completed Jul 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants