Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

SX1261/2 Datasheet Reference (Driver Development Extract)

Source: Semtech SX1261/2 Data Sheet, Rev 2.2, DS.SX1261-2.W.APP, December 2024.

This document extracts the sections relevant for SX1262 LoRa driver development. For the complete datasheet, see semtech.com.

8. Digital Interface and Control

The SX1261/2 is controlled via a serial SPI interface and a set of general purpose input/output (DIOs). At least one DIO must be used for IRQ and the BUSY line is mandatory. BUSY indicates that the chip is ready for new command only if this signal is low.

8.1 Reset

A complete “factory reset” can be issued by toggling pin NRESET. It is automatically followed by the standard calibration procedure and any previous context is lost. The pin should be held low for typically 100us for the Reset to happen.

8.2 SPI Interface

The SPI interface uses a synchronous full-duplex protocol: CPOL = 0, CPHA = 0 (Mode 0). Only the slave side is implemented.

  • MOSI is generated by the master on the falling edge of SCK and is sampled by the slave on the rising edge of SCK.
  • MISO is generated by the slave on the falling edge of SCK.
  • A transfer is always started by the NSS pin going low. MISO is high impedance when NSS is high.
  • SPI runs on the external SCK clock to allow high speed up to 16 MHz.

SPI Timing Requirements (Table 8-1)

SymbolDescriptionMinMaxUnit
t1NSS falling to SCK setup time32-ns
t2SCK period62.5-ns
t6NSS falling to MISO delay015ns
t7SCK falling to MISO delay015ns
t8SCK to NSS rising hold time31.25-ns
t9NSS high time125-ns
t10NSS falling to SCK setup when switching from SLEEP to STDBY_RC100-us
t11NSS falling to MISO delay when switching from SLEEP to STDBY_RC0150us

8.2.2 SPI Timing When Leaving Sleep Mode

One way for the chip to leave Sleep mode is to wait for a falling edge of NSS. The delay between the falling edge of NSS and the first rising edge of SCK must take into account the wake-up sequence and the chip initialization. During Sleep mode and the initialization phase, BUSY is set high. Once the chip is in STDBY_RC mode, BUSY goes low and the host can start sending a command. This is also true for startup at battery insertion or after a hard reset.

8.3.1 BUSY Control Line

The BUSY control line indicates the status of the internal state machine. When BUSY is held low, the internal state machine is in idle mode and the radio is ready for a command.

For all “write” commands, BUSY is asserted high after time T_SW. T_SW from NSS rising edge to BUSY rising edge is max 600 ns in all cases.

“Read” commands are handled directly without the internal state machine and BUSY remains low after a read command.

Switching Times (Table 8-2)

TransitionT_SW_Mode Typical (us)
SLEEP to STBY_RC cold start3500
SLEEP to STBY_RC warm start340
STBY_RC to STBY_XOSC31
STBY_RC to FS50
STBY_RC to RX83
STBY_RC to TX126
STBY_XOSC to TX105

8.4 Digital Interface Status versus Chip Modes (Table 8-3)

ModeDIO3DIO2DIO1BUSYMISOMOSISCKNSS
ResetPDPDPDPUHIZHIZHIZIN
Start-upPDPDPDPUHIZHIZHIZIN
SleepPDPDPDPUHIZHIZHIZIN
STBY_RCOUTOUTOUTOUTOUTINININ
STBY_XOSCOUTOUTOUTOUTOUTINININ
FS / RX / TXOUTOUTOUTOUTOUTINININ

PU = pull up 50kOhm, PD = pull down 50kOhm, HIZ = high impedance, OUT = output, IN = input.

During Reset, Start-up, and Sleep: MISO is High-Impedance. Any SPI read during these states returns undefined data.

8.5 IRQ Handling (Table 8-4)

BitIRQDescriptionModulation
0TxDonePacket transmission completedAll
1RxDonePacket receivedAll
2PreambleDetectedPreamble detectedAll
3SyncWordValidValid Sync Word detectedFSK
4HeaderValidValid LoRa Header receivedLoRa
5HeaderErrLoRa Header CRC errorLoRa
6CrcErrWrong CRC receivedAll
7CadDoneChannel activity detection finishedLoRa
8CadDetectedChannel activity detectedLoRa
9TimeoutRx or Tx TimeoutAll

Note: If DIO2 or DIO3 are used to control the RF Switch or the TCXO, the IRQ is not generated even if it is mapped to the pins.

9. Operational Modes

Operating Modes (Table 9-1)

ModeEnabled Blocks
SLEEPOptional registers, backup regulator, RC64k oscillator, data RAM
STDBY_RCTop regulator (LDO), RC13M oscillator
STDBY_XOSCTop regulator (DC-DC or LDO), XOSC
FSAll of the above + Frequency synthesizer at Tx frequency
TXFrequency synthesizer and transmitter, Modem
RXFrequency synthesizer and receiver, Modem

9.1 Startup

At power-up or after a reset, the chip goes into STARTUP state. The BUSY pin is set to high. When the digital voltage and RC clock become available, the chip can boot up and the CPU takes control. At this stage the BUSY line goes down and the device is ready to accept commands.

9.2 Calibration

The calibration procedure is automatically called in case of POR. Blocks calibrated: RC64k, RC13M, PLL, RX ADC, Image. Once calibration is finished, the chip enters STDBY_RC mode.

9.2.1 Image Calibration for Specific Frequency Bands (Table 9-2)

Frequency Band [MHz]Freq1Freq2
430 - 4400x6B0x6F
470 - 5100x750x81
779 - 7870xC10xC5
863 - 8700xD70xDB
902 - 9280xE1 (default)0xE9 (default)

By default, the image calibration is made in the 902-928 MHz band. When using a TCXO, the calibration fails and the user should request a complete calibration after calling SetDIO3AsTcxoCtrl(...).

9.7 Transmit (TX) Mode

In TX mode, after enabling and ramping-up the Power Amplifier (PA), the contents of the data buffer are transmitted. The timeout can be used as a security to ensure that if the TxDone IRQ is never triggered, the TxTimeout prevents waiting indefinitely. In TX mode, BUSY goes low as soon as the PA has ramped-up and transmission of preamble starts.

10. Host Controller Interface

10.1 Command Structure (Table 10-1)

Byte0[1:n]
Data from host (MOSI)OpcodeParameters
Data to host (MISO)RFUStatus

During byte 0 (the opcode byte), MISO returns RFU (Reserved for Future Use) – NOT the status byte. The status byte appears starting at byte 1.

10.2 Transaction Termination

The host terminates an SPI transaction with the rising NSS signal. The host must not raise NSS within the bytes of a transaction. All parameters must be sent before raising NSS.

11. List of Commands

11.1 Operational Mode Commands (Table 11-1)

CommandOpcodeParametersDescription
SetSleep0x84sleepConfigSet Chip in SLEEP mode
SetStandby0x80standbyConfigSet Chip in STDBY_RC or STDBY_XOSC mode
SetFs0xC1-Set Chip in Frequency Synthesis mode
SetTx0x83timeout[23:0]Set Chip in Tx mode
SetRx0x82timeout[23:0]Set Chip in Rx mode
SetCad0xC5-Set chip in RX mode with CAD parameters
SetTxContinuousWave0xD1-Test command: CW at selected frequency
SetRegulatorMode0x96regModeParamSelect LDO or DC_DC+LDO
Calibrate0x89calibParamCalibrate RC13, RC64, ADC, PLL, Image
CalibrateImage0x98freq1, freq2Image calibration at given frequencies
SetPaConfig0x95paDutyCycle, HpMax, deviceSel, paLUTConfigure PA
SetRxTxFallbackMode0x93fallbackModeMode after TX/RX done

11.2 Register and Buffer Access Commands (Table 11-2)

CommandOpcodeParameters
WriteRegister0x0Daddress[15:0], data[0:n]
ReadRegister0x1Daddress[15:0]
WriteBuffer0x0Eoffset, data[0:n]
ReadBuffer0x1Eoffset

11.3 DIO and IRQ Control (Table 11-3)

CommandOpcodeParameters
SetDioIrqParams0x08IrqMask[15:0], Dio1Mask[15:0], Dio2Mask[15:0], Dio3Mask[15:0]
GetIrqStatus0x12-
ClearIrqStatus0x02ClearIrqParam[15:0]
SetDIO2AsRfSwitchCtrl0x9Denable
SetDIO3AsTcxoCtrl0x97tcxoVoltage, timeout[23:0]

11.4 RF, Modulation and Packet Commands (Table 11-4)

CommandOpcodeParameters
SetRfFrequency0x86rfFreq[31:0]
SetPacketType0x8Aprotocol
SetTxParams0x8Epower, rampTime
SetModulationParams0x8BModParam1..8
SetPacketParams0x8C(preamble, header, payload, crc, iq)
SetBufferBaseAddress0x8FTX base address, RX base address
SetLoRaSymbNumTimeout0xA0SymbNum

13. Command Details (Selected)

13.1.2 SetStandby

Byte01
Data from host0x80StdbyConfig

StdbyConfig: 0 = STDBY_RC, 1 = STDBY_XOSC.

13.1.4 SetTx

Byte01-3
Data from host0x83timeout[23:0]
  • Starting from STDBY_RC mode, the oscillator is switched ON followed by PLL, then the PA ramps up.
  • When the last bit has been sent, an IRQ TX_DONE is generated, the PA ramps down, and the chip goes back to STDBY_RC mode.
  • A TIMEOUT IRQ is triggered if TX_DONE is not generated within the timeout period.
  • Timeout duration = Timeout * 15.625us
  • Timeout = 0x000000: No timeout, device stays in TX until packet is transmitted and returns to STBY_RC.

13.1.5 SetRx

Byte01-3
Data from host0x82timeout[23:0]
TimeoutDuration
0x000000Single mode: stays in RX until reception, then returns to STBY_RC
0xFFFFFFContinuous mode: remains in RX until host sends a mode change command
OthersTimeout active: returns to STBY_RC on timeout or reception. Max timeout is 262s.

13.1.11 SetRegulatorMode

Byte01
Data from host0x96regModeParam

regModeParam: 0 = Only LDO, 1 = DC_DC+LDO (used for STBY_XOSC, FS, RX and TX modes).

13.1.12 Calibrate Function

Byte01
Data from host0x89calibParam

calibParam is a bitmask: Bit 0=RC64k, 1=RC13M, 2=PLL, 3=ADC pulse, 4=ADC bulk N, 5=ADC bulk P, 6=Image. 0x7F = calibrate all. Total calibration time ~3.5ms. BUSY is high during calibration.

13.1.14 SetPaConfig

Byte01234
Data from host0x95paDutyCyclehpMaxdeviceSelpaLut
  • deviceSel: 0 = SX1262, 1 = SX1261
  • paLut: reserved, always 0x01
  • For SX1262, paDutyCycle should not be higher than 0x04.

PA Optimal Settings (Table 13-21)

Output PowerpaDutyCyclehpMaxdeviceSelpaLutSetTxParams power
+22dBm0x040x070x000x01+22dBm
+20dBm0x030x050x000x01+22dBm
+17dBm0x020x030x000x01+22dBm
+14dBm0x020x020x000x01+22dBm

13.1.15 SetRxTxFallbackMode

Byte01
Data from host0x93fallbackMode
Fallback ModeValueDescription
FS0x40Go to FS mode after TX/RX
STDBY_XOSC0x30Go to STDBY_XOSC after TX/RX
STDBY_RC0x20Go to STDBY_RC after TX/RX (default)

13.2.1 WriteRegister

Byte0123n
MOSI0x0Daddr[15:8]addr[7:0]data@addrdata@addr+(n-3)
MISORFUStatusStatusStatusStatus

13.2.2 ReadRegister

Byte01234
MOSI0x1Daddr[15:8]addr[7:0]NOPNOP
MISORFUStatusStatusStatusdata@addr

Note: The host must send an NOP after the 2 bytes of address to start receiving data bytes on the next NOP sent.

13.2.3 WriteBuffer

Byte012n
MOSI0x0Eoffsetdata@offsetdata@offset+(n-2)
MISORFUStatusStatusStatus

13.2.4 ReadBuffer

Byte0123
MOSI0x1EoffsetNOPNOP
MISORFUStatusStatusdata@offset

Note: An NOP must be sent after sending the offset.

13.3.1 SetDioIrqParams

Byte01-23-45-67-8
Data from host0x08IrqMask[15:0]DIO1Mask[15:0]DIO2Mask[15:0]DIO3Mask[15:0]

The interrupt causes a DIO to be set if the corresponding bit in DioxMask AND IrqMask are both set. For example, to route TxDone to DIO1: set bit 0 of both IrqMask and DIO1Mask.

13.3.3 GetIrqStatus

Byte012-3
MOSI0x12NOPNOP
MISORFUStatusIrqStatus[15:0]

13.3.4 ClearIrqStatus

Byte01-2
MOSI0x02ClearIrqParam[15:0]

13.3.5 SetDIO2AsRfSwitchCtrl

Byte01
MOSI0x9Denable

enable=1: DIO2 controls RF switch. DIO2=1 during TX, DIO2=0 otherwise.

13.3.6 SetDIO3AsTcxoCtrl

Byte012-4
MOSI0x97tcxoVoltagedelay[23:0]

tcxoVoltage (Table 13-35)

ValueOutput Voltage
0x001.6V
0x011.7V
0x021.8V
0x032.2V
0x063.0V
0x073.3V

Delay duration = delay[23:0] * 15.625us

The XOSC_START_ERR flag is raised at POR or wake-up from Sleep in cold-start condition when TCXO is used. This is expected and should be cleared with ClearDeviceErrors.

Note: The user should take the delay period into account when going into Tx or Rx mode from STDBY_RC mode, since the time needed to switch modes increases with the duration of delay.

13.4.1 SetRfFrequency

Byte01-4
MOSI0x86RfFreq[31:0]

RF_frequency = RF_Freq * F_XTAL / 2^25, where F_XTAL = 32 MHz.

To compute RF_Freq from Hz: RF_Freq = freq_hz * 2^25 / 32_000_000

13.4.4 SetTxParams

Byte012
MOSI0x8EpowerRampTime

power: -9 to +22 dBm (encoded as 0xF7 to 0x16) for high power PA (SX1262).

RampTimeValueTime (us)
SET_RAMP_10U0x0010
SET_RAMP_20U0x0120
SET_RAMP_40U0x0240
SET_RAMP_80U0x0380
SET_RAMP_200U0x04200
SET_RAMP_800U0x05800

13.4.5 SetModulationParams (LoRa)

Byte012345-8
MOSI0x8BSFBWCRLdOptunused (0x00)
  • ModParam1 = SF (Spreading Factor)
  • ModParam2 = BW (Bandwidth)
  • ModParam3 = CR (Coding Rate)
  • ModParam4 = LdOpt (Low Data Rate Optimization)

13.5.1 GetStatus

Byte01
MOSI0xC0NOP
MISORFUStatus

Status Byte Format (Table 13-76)

Bit 7Bits 6:4Bits 3:1Bit 0
ReservedChip modeCommand statusReserved

Chip mode:

ValueMode
0x0Unused
0x2STBY_RC
0x3STBY_XOSC
0x4FS
0x5RX
0x6TX

Command status:

ValueMeaning
0x0Reserved
0x2Data is available to host
0x3Command timeout
0x4Command processing error
0x5Failure to execute command
0x6Command TX done

13.5.2 GetRxBufferStatus

Byte0123
MOSI0x13NOPNOPNOP
MISORFUStatusPayloadLengthRxRxStartBufferPointer

13.5.3 GetPacketStatus (LoRa)

Byte01234
MOSI0x14NOPNOPNOPNOP
MISORFUStatusRssiPktSnrPktSignalRssiPkt
  • Actual signal power = -RssiPkt/2 (dBm)
  • Actual SNR = SnrPkt/4 (dB)

15. Known Limitations

15.1 Modulation Quality with 500kHz LoRa Bandwidth

Before any packet transmission, bit #2 at register address 0x0889 shall be set to:

  • 0 if the LoRa BW = 500kHz
  • 1 for any other LoRa BW or (G)FSK configuration

Must be applied before each packet transmission.

15.2 Better Resistance to Antenna Mismatch (TX PA Clamp)

During chip initialization on the SX1262, the register TxClampConfig at address 0x08D8 should be modified. Bits 4-1 must be set to “1111” (default value “0100”).

value = ReadRegister(0x08D8)
value = value | 0x1E
WriteRegister(value, 0x08D8)

Must be done after POR or wake-up from cold start.

15.3 Implicit Header Mode Timeout Behavior

After ANY Rx with Timeout active sequence, stop the RTC and clear the timeout event:

WriteRegister(0x00, 0x0920)
value = ReadRegister(0x0944)
value = value | 0x02
WriteRegister(value, 0x0944)

15.4 Optimizing the Inverted IQ Operation

Bit 2 at address 0x0736 must be set to:

  • “0” when using inverted IQ polarity
  • “1” when using standard IQ polarity

Key Register Addresses

AddressNameDescription
0x0740LoRaSyncwordLoRa sync word (2 bytes, MSB first). 0x1424=private, 0x3444=public.
0x0889TxModulationBW500 workaround (bit 2)
0x08ACRxGain0x94=power saving (default), 0x96=boosted gain
0x08D8TxClampConfigPA clamp workaround (bits 4:1 = 0xF)
0x0736IqPolarityInverted IQ workaround (bit 2)
0x0902RtcControlRTC stop (write 0x00 after Rx with timeout)
0x0944EventMaskClear timeout event (bit 1)
0x029FRetentionList countNumber of retention registers
0x02A0-0x02A1RetentionList[0]First retention register address (0x08AC)

Init Sequence Summary (from Semtech reference driver + RNode)

  1. Hardware reset (NRESET LOW 100us, HIGH, wait BUSY LOW)
  2. SetStandby(STBY_RC) [0x80, 0x00]
  3. SetRegulatorMode(DC_DC) [0x96, 0x01]
  4. SetDIO2AsRfSwitchCtrl(enable) [0x9D, 0x01]
  5. ClearDeviceErrors [0x07, 0x00, 0x00]
  6. SetDIO3AsTcxoCtrl(1.8V, timeout) [0x97, 0x02, t2, t1, t0]
  7. Calibrate(all) [0x89, 0x7F] — wait BUSY LOW (~3.5ms)
  8. CalibrateImage(863-870MHz) [0x98, 0xD7, 0xDB]
  9. SetPacketType(LoRa) [0x8A, 0x01]
  10. SetRfFrequency(freq) [0x86, f3, f2, f1, f0]
  11. SetPaConfig(0x04, 0x07, 0x00, 0x01) for +22dBm SX1262
  12. SetTxParams(power, ramp) [0x8E, pwr, ramp]
  13. SetBufferBaseAddress(0, 0) [0x8F, 0x00, 0x00]
  14. SetModulationParams(SF, BW, CR, LDRO) [0x8B, sf, bw, cr, ldro, 0,0,0,0]
  15. SetPacketParams(preamble, header, len, crc, iq) [0x8C, ...]
  16. Write LoRa sync word to register 0x0740
  17. Apply workarounds: TxClamp (0x08D8), BW500 (0x0889), IQ (0x0736)
  18. Set RxGain to 0x96 (boosted) at register 0x08AC

TX Sequence

  1. SetDioIrqParams(TxDone|Timeout on DIO1) [0x08, mask_hi, mask_lo, dio1_hi, dio1_lo, 0,0, 0,0]
  2. ClearIrqStatus(all) [0x02, 0xFF, 0xFF]
  3. WriteBuffer(0, payload) [0x0E, 0x00, data...]
  4. SetTx(timeout) [0x83, t2, t1, t0] — timeout=0 for no timeout
  5. Wait for DIO1 HIGH (TxDone IRQ)
  6. ClearIrqStatus(TxDone) [0x02, 0x00, 0x01]

RX Sequence

  1. SetDioIrqParams(RxDone|Timeout|CrcErr on DIO1)
  2. ClearIrqStatus(all) [0x02, 0xFF, 0xFF]
  3. SetRx(timeout) [0x82, t2, t1, t0]
  4. Wait for DIO1 HIGH
  5. GetIrqStatus — check RxDone vs Timeout vs CrcErr
  6. GetRxBufferStatus [0x13, ...] — get length + start pointer
  7. ReadBuffer(start, length) [0x1E, start, NOP, data...]
  8. GetPacketStatus [0x14, ...] — get RSSI, SNR
  9. ClearIrqStatus
  10. Apply workaround 15.3 (stop RTC after Rx with timeout)