2025-08-26 4:20 AM
Hi everyone,
I am using STM32F103c8t6 module for transmitting and receiving data in between two SX1262 LoRa module.
The libraries are found in https://github.com/Lora-net/sx126x_driver/tree/v2.3.2 link and i have successfully transmit and receive data using normal SPI communication but i want to transmit and receive the data using SPI DMA mode but i am unable to do that.
If anyone know about this please guide me regarding this.
Thank you in advance!!
2025-08-26 4:27 AM - edited 2025-08-26 4:47 AM
The SX1262 neither knows nor cares how the SPI lines get driven - it just requires that they are correct.
So put an analyser on the lines, and compare what happens in your working non-DMA case against your non-working DMA case.
Are you using the exact same hardware in both cases?
PS:
Also, have you tried the drivers direct from Semtech?
https://www.semtech.com/products/wireless-rf/lora-connect/sx1262
2025-08-26 4:39 AM
And since you're talking about an "STM32F103c8t6 module", I assume it's a Blue Pill?
If so, hardly anyone will be able to help you, as Asian clones have been used there for years. You would be doing yourself a favour to use one of the original, genuine NUCLEO boards instead, for which there is unrestricted support.
Regards
/Peter
2025-08-26 6:01 AM
Thank you
Yes, i am using blue pill at transmitter end and receiver end. Yes i am using the driver for sx1262 from semtech.
By following way i am initializing
init_LoRa_parm();
sx126x_reset(&LoRa);
sx126x_init(&LoRa );
sx126x_set_dio2_as_rf_sw_ctrl(&LoRa, true);
sx126x_set_dio3_as_tcxo_ctrl(&LoRa, SX126X_TCXO_CTRL_1_8V, 0x00000F);
sx126x_get_device_errors(&LoRa, &errors);
printf("before STDBY_XOSC, Errors = 0x%X\r\n", errors);
sx126x_set_standby(&LoRa, SX126X_STANDBY_CFG_XOSC);
sx126x_clear_device_errors( &LoRa);
sx126x_get_device_errors(&LoRa, &errors);
printf("After STDBY_XOSC, Errors = 0x%X\r\n", errors);
Radio_init(&LoRa);
sx126x_clear_irq_status( &LoRa, SX126X_IRQ_ALL );
sx126x_set_dio_irq_params(
&LoRa, SX126X_IRQ_ALL,
SX126X_IRQ_TX_DONE | SX126X_IRQ_RX_DONE,
SX126X_IRQ_NONE, SX126X_IRQ_NONE );
sx126x_clear_irq_status( &LoRa, SX126X_IRQ_ALL );
and in main loop i am putting the following function
void on_tx_data(void)
{
sx126x_status_t status;
// Prepare data
for (int i = 0; i < 8; i++) {
tx_buf[i] = counter++;
}
// Write buffer with error checking
status = sx126x_write_buffer(&LoRa, 0, (const uint8_t*)tx_buf, 8);
if (status != SX126X_STATUS_OK) {
printf("Write buffer failed: %d\n", status);
return;
}
// Set TX mode with error checking
status = sx126x_set_tx(&LoRa, 0);
if (status != SX126X_STATUS_OK) {
printf("Set TX failed: %d\n", status);
return;
}
// Print transmitted data
printf("Sent: ");
for (int i = 0; i < 8; i++) {
printf("%d ", tx_buf[i]);
}
printf("\r\n");
}
where tx_buf is the global variable.
and
void init_LoRa_parm(void)
{
txdata[0] = 'M';
txdata[1] = 'L';
txdata[2] = 'o';
txdata[3] = 'R';
txdata[4] = 'a';
LoRa.BUSY_port = BUSY_GPIO_Port;
LoRa.BUSY_pin = BUSY_Pin;
LoRa.NSS_port = NSS_GPIO_Port;
LoRa.NSS_pin = NSS_Pin;
LoRa.RST_port = RST_GPIO_Port;
LoRa.RST_pin = RST_Pin;
LoRa.DIO1_port = DIO1_GPIO_Port;
LoRa.DIO1_pin = DIO1_Pin;
LoRa.hSPIx = &hspi1;
}
this is the initialization value.
By taking this guide me to transmit the data over SPI DMA mode.
2025-08-26 6:04 AM
At least the SPI DMA transmission and reception operation will work on bluepill as the normal transmit and receive operation is occuring frequently.
2025-08-26 6:39 AM - edited 2025-08-26 6:40 AM
@Shaktimayee wrote:At least the SPI DMA transmission and reception operation will work on bluepill as the normal transmit and receive operation is occuring frequently.
Not sure what you mean by that?
It might be the clone's DMA which is the problem ...
Again, have you used a scope and/or analyser to see what's actually happening on the SPI wires?
PS:
Have you tried with a genuine STM32?