Help needed please, with SX1262 tranceivers not receiving any data!

Started by top204, Mar 20, 2025, 03:32 PM

Previous topic - Next topic

top204

Hello All

I need some help, if possible, in getting a pair of SX1262 tranceivers working.

Using trastikata's original code template, changed for the LAMBDA62 boards using a 32MHz oscillator for the SX1262 device, they transmit, but do not receive. So I worked on the code and made it follow the datasheet to the letter (and there are a lot of letters in that datasheet :-) ), but I still cannot get the SX1262 device to receive anything, and its DIO1 line never moves, and if I read the status, nothing is being received?

I know the transmitter is working, because I can see it on an SDR (See the attached image), but I cannot get it to receive, and I have tried many, many code iterations! Please help...

The source code is attached in a zip file named: "SX1262_TX_RX_Code.zip", and the code is written for a PIC18F26K40 device, but it does not use any of its peripherals for SPI, so a  change for another device will be very simple. The source codes are for transmit and receive and a library that has many procedures and setups for the SX126x devices.

Attached is a screenshot of the transmitter, and it seems to be working as it should, with the correct frequency (868 MHz) and the correct pulses for what is being transmitted etc... So why no receive at all?

Any help will be very much appreciated, on any frequency that your module uses, as I am now going around in circles changing this and that and still no receive!!.

When the code it is up and running, I will release the source code as a library for the compilers, and make it a standard include that gets installed with the compilers.

SDR Screenshot of 868 MHz.jpg

Best regards
Les


trastikata

Hello Les,

There was a particular issue with the sync word for SX1262, can't remember exactly what and I am not home to look it on I-net, but if you google it, there will be plenty explanation of it.

Regards

Pepe

Other than the recommended sync words 0x1424 and 0x3444 work fine in our test setup in combination with 0x12 and 0x34 on the SX1276, but we didn't test how reliable the communication is, e.g. across different units of the SX1262, or at different operating temperatures, or with QRM or QRN.

https://blog.classycode.com/lora-sync-word-compatibility-between-sx127x-and-sx126x-460324d1787a

trastikata

Hello Les,

I've just noticed that the chirping in your SDR screenshot doesn't look like LoRa signal. Take a look at my post here, how the LoRa signal looks like:

https://protoncompiler.com/index.php?msg=18753


top204

QuoteI've just noticed that the chirping in your SDR screenshot doesn't look like LoRa signal.

That's what I thought as well?

But the SX device is being set to LoRa mode in the SX1262_Init procedure, and the code to perform it is correct:

SX_SendCommand1(cSX_CMD_SET_PACKET_TYPE, cSX_VAL_cLORA_MODEM' Define the protocol as LoRa

Where the cSX_CMD_SET_PACKET_TYPE value is:

$define cSX_CMD_SET_PACKET_TYPE $8A

And the cSX_VAL_cLORA_MODEM value is:

$define cSX_VAL_cLORA_MODEM    $01

And the SX_SendCommand1 procedure is:

'------------------------------------------------------------------------------------------------------------
' Send a command and one 8-bit value to the SX device
' Input     : pCmd holds the command to send
'           : pDat1 holds the 8-bit values to send
' Output    : None
' Notes     : None
'
Proc SX_SendCommand1(pCmd As Byte, pDat1 As SX_bPrmDat1)
    SX_SPI_Start()                                                                  ' Start an SPI communication
        SPI_WriteByte(pCmd)                                                         ' Send the command value
        SPI_WriteByte(pDat1)                                                        ' Send data byte 1
    SX_SPI_End()                                                                    ' End an SPI communication
    SX_WaitFor_NotBusy()                                                            ' Wait for the SX device to be ready
EndProc
 
Where the SX_WaitFor_NotBusy procedure also has a delay before looking for a BUSY pin change.

A value of $00 would change it to 'GFSK' mode, and $03 would use 'Long Range FHSS'.

I have also tried the standard public and private sync words and still no receive. i.e. $3444 for Public Network, and $1424 for Private Network. I am now going potty, and do not actually know were else to look for a problem?     

top204

If I zoom in the waterfall on the SDR, it can be seen that data is sent, and that it is using spread spectrum based upon the bandwidth value:

SDR.jpg

CPR

Here's something to perhaps help and compare your code against? It's a detailed walkthrough - for Arduino - in C++ which you'll be familiar with - but for a RA-01/02 LORA Module. Which only slightly differs (SX1268) from the SX1262 chip. There's a few other changes involving the RF switching. TXEN and RXEN on the LAMBDA 62 both need to be controlled externally. On the RA-01 they don't.
Perhaps a pointer & something to look at.

https://circuitstate.com/ra01esp32

I'd use the MSSP hardware rather than making a soft library (IMHO)

OFF TOPIC - but -

(Also a response on the the outstanding "anomaly" here - https://protoncompiler.com/index.php/topic,2463.msg19650.html#msg19650)
No apologies for pressing the point.

And, as well - https://protoncompiler.com/index.php/topic,2587.0.html


Fanie

Perhaps hard wire your RX TX boards and see if you get the expected communication.

trastikata

Quote from: trastikata on Mar 20, 2025, 04:07 PMThere was a particular issue with the sync word for SX1262, can't remember exactly what and I am not home to look it on I-net, but if you google it, there will be plenty explanation of it.

Hello Les,

I am back home and had some time to test your code. I was right, the issue is indeed with the sync word, however I had to look in my notes to remember what exactly the particularity with SX126x was. This is probably the biggest, I'd say undocumented errata or bug in SX126x.

The sync word has not the typical meaning as in other RF devices, the Low or High byte can not be zero and the first and third nibbles should be 4 because they seem to play some undocumented role in the device settings. More than that, the two nibbles Y and Z of the sync word should both be in the range 1 to 7, and the corresponding 2-byte sync word in the SX126x is 0xY4Z4 ... imagine the time and effort it took for people to find this out empirically.

If you look in my reference code that I posted earlier, the sync word is 0x64, however I update only the cSX_REG_SX_SYNC_WORD_MSB register with that value and the default value in the sync word LSB remains 0x24. So the resulting sync word is 0x6424 which is valid according the former requirement (0xY4Z4 where Y and Z are 1 to 7).

    bSyncByte= 0x64

    'Define Sync Word value and write in Sync Word Byte 0 
    Low CS
        SpiSend(CMD_WRITE_REGISTER )
        SpiSend(REG_LORA_SYNC_WORD_MSB.Byte1)
        SpiSend(REG_LORA_SYNC_WORD_MSB.Byte0)
        SpiSend(bSyncByte)
    High CS

In your code in SX126x.inc you update the sync word sequentially as Word variable starting from cSX_REG_SX_SYNC_WORD_MSB where you write pSync.Byte1 and then pSync.Byte0. With the sync word of your example i.e. 0x64, it overwrote the MSB of the sync word to 0x00 which is not a valid value:

'------------------------------------------------------------------------------------------------------------
' Setup the Sync word value
' Input     : pSync holds the 16-bit sync value
' Output    : None
' Notes     : Set to $3444 for Public Network
'           : Set to $1424 for Private Network
'
Proc SX_SetSyncWord(pSync As Word)
    SX_SPI_Start()                                                                      ' Start an SPI communication
    SPI_WriteByte(cSX_CMD_WRITE_REGISTER )                                              ' Send the Op-Code to the SX device to write to a register
    SPI_WriteByte(cSX_REG_SX_SYNC_WORD_MSB.Byte1)                                       ' Send the register address high byte
    SPI_WriteByte(cSX_REG_SX_SYNC_WORD_MSB.Byte0)                                       ' Send the register address low byte
    SPI_WriteByte(pSync.Byte1)                                                          ' Send the sync value high byte
    SPI_WriteByte(pSync.Byte0)                                                          ' Send the sync value low byte
    SX_SPI_End()                                                                        ' End an SPI communication
    SX_WaitFor_NotBusy()                                                                ' Wait for the SX device to be ready
EndProc

Further I am not sure if you are allowed to write sequentially in those registers. To caution on the safe side I'd write in separate steps pSync.Byte1 and pSync.Byte0 to registers REG_LORA_SYNC_WORD_MSB and REG_LORA_SYNC_WORD_LSB



Edit: After those modifications for the sync word and changing the PIC pins to fit my test devices, I tried your code (modified cBoard_Crystal_Freq  26 to reflect the 26 MHz TCXO in my modules) and your RX and TX code works. If you want I can post the modified code but the main difference is here:

'Fully define the Sync word within the valid range as 0x6424

SX1262_Init(435.321,      16,              $6424,       cSX_PayLoadLength)  
...
Proc SX1262_Init(pFrequency As Float, pPreambleLength As Byte, pSyncWord As Word, pPacketLen As SX_bPacketLen)
...
  SX_SetSyncWord(pSyncWord)
...
EndProc

Proc SX_SetSyncWord(pSync As Word)
    SX_SPI_Start()                                                                      ' Start an SPI communication
    SPI_WriteByte(cSX_CMD_WRITE_REGISTER )                                              ' Send the Op-Code to the SX device to write to a register
    SPI_WriteByte(cSX_REG_SX_SYNC_WORD_MSB.Byte1)                                       ' Send the register address high byte
    SPI_WriteByte(cSX_REG_SX_SYNC_WORD_MSB.Byte0)                                       ' Send the register address low byte
    SPI_WriteByte(pSync.Byte1)                                                          ' Send the sync value high byte
    SX_SPI_End()                                                                        ' End an SPI communication
    SX_WaitFor_NotBusy()                                                                ' Wait for the SX device to be ready
   
    SX_SPI_Start()                                                                      ' Start an SPI communication
    SPI_WriteByte(cSX_CMD_WRITE_REGISTER )                                              ' Send the Op-Code to the SX device to write to a register
    SPI_WriteByte(cSX_REG_SX_SYNC_WORD_LSB.Byte1)                                       ' Send the register address high byte
    SPI_WriteByte(cSX_REG_SX_SYNC_WORD_LSB.Byte0)                                       ' Send the register address low byte
    SPI_WriteByte(pSync.Byte0)                                                          ' Send the sync value low byte
    SX_SPI_End()                                                                        ' End an SPI communication
    SX_WaitFor_NotBusy()                                                                ' Wait for the SX device to be ready  
EndProc