Hi,
I’m using SX1262 transceiver to communicate with a remote board via LoRa. Even though the communication succeeds, the data is properly sent and received, I cannot change the write buffer content. I probably tested any combination possible of commands sequence, but still failing to save any data. I’m using Semtech dedicated driver (link: https://github.com/Lora-net/sx126x_driver/tree/master) with hal library implementation. VDD is 3.31V. SPI speed 2.5MHz.
Documentation I based on: https://semtech.my.salesforce.com/sfc/p/#E0000000JelG/a/2R000000Un7F/yT.fKdAr9ZAo3cJLc4F2cBdUsMftpT2vsOICP7NmvMo
SPI communication also seems working fine. Communication process below:
Radio Init code:
void SXInit(void)
{
ClearBuffer(zeros, BUFFER_LEN);
const sx126x_pa_cfg_params_t pa_cfg = {0x04, 0x07, 0x00, 0x01}; // optimal params p.79
const sx126x_mod_params_lora_t lora_cfg = {SX126X_LORA_SF8, SX126X_LORA_BW_125, SX126X_LORA_CR_4_8, 0x00}; // s.89 0x0C - SF12,
// 0x06 BW 500kHz, 0x04 CR correction bytes
const sx126x_pkt_params_lora_t lora_pkt = {0x1F, SX126X_LORA_PKT_EXPLICIT, 0x20, 0x01, 0x00}; //0x0010 preamble length, 0x00
// header type, payload max length, crc off, standard IQ setupsx126x_hal_reset(NULL);
sx126x_set_standby(NULL, SX126X_STANDBY_CFG_RC); // set cfg = 1, TCXO clock mode, cfg = 0 RC 13MHz
sx126x_cal_img_in_mhz(NULL, 0xD7, 0xDB); //from 863 to 870 MHz calibrationsx126x_cal(NULL, SX126X_CAL_ALL);
sx126x_set_reg_mode(NULL, SX126X_REG_MODE_DCDC);
sx126x_set_dio2_as_rf_sw_ctrl(NULL, true); //enable dio2 as rf ctrl
sx126x_set_dio3_as_tcxo_ctrl(NULL, SX126X_TCXO_CTRL_3_3V, 0xFF); //0x07 - 3v3, timeoutsx126x_set_dio_irq_params(NULL, SX126X_IRQ_ALL, SX126X_IRQ_ALL, 0x0000, 0x0000);
sx126x_set_pkt_type(NULL, SX126X_PKT_TYPE_LORA); // set pkt type = 1 LoRa, 0 (G)FSK, 3 Long Range FHSS
// sx126x_write_buffer(NULL, 0x00, zeros, 100); //next is payload p.101 // this command here, blocks radio transmission GetStatus() // 0xC0 returns CMD_EXEC_FAILURE, even though this sequence is recommended by semtech documentationsx126x_set_rf_freq(NULL, 867000000); // freq in hz
sx126x_set_pa_cfg(NULL, &pa_cfg);
sx126x_set_tx_params(NULL, 22, 0x05); // ramp time = 0x05 800us, p.86
sx126x_set_buffer_base_address(NULL, 0x00, 0x00); // tx address and rx addresssx126x_set_lora_mod_params(NULL, &lora_cfg);
sx126x_set_lora_pkt_params(NULL, &lora_pkt);
}
Send TX code:
void SX1262SendData(uint8_t* data, uint16_t length)
{
sx126x_write_buffer(NULL, 0x05, data, length);
sx126x_get_status(NULL, &status);
sx126x_set_tx(NULL, 0xFF); //SX126X_MAX_TIMEOUT_IN_RTC_STEP
}
DIO1 interrupt handling and reading write_buffer
sx126x_get_status(NULL, &status);
sx126x_get_irq_status(NULL, &irq);
switch(irq)
{
case SX126X_IRQ_TX_DONE:
sx126x_set_standby(NULL, SX126X_STANDBY_CFG_RC);
ClearBuffer(data_buffer, 255); //overrites data_buffer with zeros
sx126x_read_buffer(NULL, 0x00, data_buffer, 255);
sx126x_get_status(NULL, &status);
break;
…
Changing write_buffer offset, payload length (in SetPacketParams) or data content itself, does not change data buffer content.
Do you have any clue, what can cause this problem?
Thanks a lot!