2022-09-21 08:51 AM
Hi,
Context:
I am currently developing a LoRa board implementing the STM32WL55. I didn't get the SubGHz Middleware to work, so i implemented the approach as detailed in the reference manual page 206.
The code compiles, and the tx-complete interrupt is getting triggered, so everything seems to work as it should.
I then tried to receive my LoRa messages with a Nucleo Board, where i modified the SubGHz_Phy_PingPong example to not send Pings anymore and print everything it recieves to the USB UART. It works perfectly when I send lora data via another Nucleo.
I saw that in the subghz_phy_app.h of the PingPong Example it says:
#define LORA_BANDWIDTH 0 /* [0: 125 kHz, 1: 250 kHz, 2: 500 kHz, 3: Reserved] */
#define LORA_SPREADING_FACTOR 7 /* [SF7..SF12] */
#define LORA_CODINGRATE 1 /* [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8] */
#define LORA_PREAMBLE_LENGTH 8 /* Same for Tx and Rx */
#define LORA_SYMBOL_TIMEOUT 64 /* Symbols */
#define LORA_FIX_LENGTH_PAYLOAD_ON false
#define LORA_IQ_INVERSION_ON false
And adjusted my settings accordingly,but the nucleo doesn't receive the lora messages from my custom board.
Question :
What are the receive parameters of the nucleo-WL55JCI7 Board Examples?
My seding code is:
//Wakeup and check for standby mode
if (HAL_SUBGHZ_ExecSetCmd(&hsubghz, RADIO_SET_SLEEP, &RadioParam, 1) != HAL_OK)
{
Error_Handler();
}
/* Set Standby Mode */
if (HAL_SUBGHZ_ExecSetCmd(&hsubghz, RADIO_SET_STANDBY, &RadioParam, 1) != HAL_OK)
{
Error_Handler();
}
/* Retrieve Status from SUBGHZ Radio */
if (HAL_SUBGHZ_ExecGetCmd(&hsubghz, RADIO_GET_STATUS, &RadioResult, 1) != HAL_OK)
{
Error_Handler();
}
else
{
/* Format Mode and Status receive from SUBGHZ Radio */
RadioMode = ((RadioResult & RADIO_MODE_BITFIELD) >> 4);
/* Check if SUBGHZ Radio is in RADIO_MODE_STANDBY_RC mode */
if(RadioMode != RADIO_MODE_STANDBY_RC)
{
Error_Handler();
}
}
//1. set Buffer base Address
buf[0] = 0x80; //TX base address
buf[1]= 0x00; //RX base address
if(HAL_SUBGHZ_ExecSetCmd(&hsubghz, RADIO_SET_BUFFERBASEADDRESS, buf,2 )!= HAL_OK ){ Error_Handler();}
//2. Fill buffer with test message
if(HAL_SUBGHZ_WriteBuffer(&hsubghz, 0x80, testMessage, 5) != HAL_OK){Error_Handler();}
//3. Set packet type (LoRa)
buf[0]= 0b00000001; //LoRa
if(HAL_SUBGHZ_ExecSetCmd(&hsubghz, RADIO_SET_PACKETTYPE, buf, 1)){Error_Handler();}
//4. Define format
buf[0]= 0; // Preamble length lsb
buf[1]= 12; //preamble lenght rsb
buf[2]= 0; //explicit header for varibale payload length
buf[3]= 5; // Payload lenght in byte
buf[4]= 1; //CRC Enabled
buf[5]= 0; //standard IQ setup
if(HAL_SUBGHZ_ExecSetCmd(&hsubghz, RADIO_SET_PACKETPARAMS , buf, 6)!= HAL_OK){Error_Handler();}
//5. Syncword, didnt find anything in the documentation i think it is only necessary for non Lora transmission
//6. Set Frequency
buf[0]= 0b00100011;
buf[1]= 0b01110110;
buf[2]= 0b10010011;
buf[3]= 0b01111100;// set to 594973564
if(HAL_SUBGHZ_ExecSetCmd(&hsubghz,RADIO_SET_RFFREQUENCY , buf, 4)){Error_Handler();}
//7. Setup PA
buf[0]= 0x2; //set dutycycle
buf[1]= 0x2; //set output power to 14dBm
buf[2]= 0; //set HP PA
buf[3]= 0x01; //random stuff that the doc wants
if(HAL_SUBGHZ_ExecSetCmd(&hsubghz, RADIO_SET_PACONFIG, buf, 4 )!=HAL_OK){Error_Handler();}
//8. Define PA output power and rampup
buf[0]= 0x16; //set power according to table 35 in the Reference manual
buf[1]= 0x02; //set rampup time to 40us
if(HAL_SUBGHZ_ExecSetCmd(&hsubghz, RADIO_SET_TXPARAMS, buf, 2)!=HAL_OK){Error_Handler();}
//9. define the modulation params
buf[0]= 0x7; //Spreading factor 7
buf[1]= 0x04; //bandwidth 125kHz
buf[2]= 0x1; //Cr 4/5
buf[3]= 0; //No Low data rate optimization
if(HAL_SUBGHZ_ExecSetCmd(&hsubghz, RADIO_SET_MODULATIONPARAMS, buf, 4)){Error_Handler();}
//10. Enable Interrupts
buf[0]= 0b00000010;// enable Txdone
buf[1]= 1; // enable timeout
buf[2]= 0b00000010;
buf[3]=1;
buf[4]= 0;
buf[5]= 0;
buf[6]= 0;
buf[7]= 0;// enable both on irq1 line
if(HAL_SUBGHZ_ExecSetCmd(&hsubghz, RADIO_CFG_DIOIRQ, buf, 8)){Error_Handler();}
//set HF switch
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_7, GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_6, GPIO_PIN_RESET);
//11. start transmission
buf[0]= 0;
buf[1]= 0b01111101;
buf[2]= 0b00000000; //set timeout to 500ms
if(HAL_SUBGHZ_ExecSetCmd(&hsubghz, RADIO_SET_TX, buf, 3)){Error_Handler();}
//12. wait for interrupt
uint8_t temp = 0;
while (!temp){
temp = Radio_Interrupt_Happened;
}
//13. clear Interrupt done by interrupt handler
2022-09-21 09:19 AM
Debugging radio is something you can bury hours/days into.
Not sure there's a lot of interest here getting into bit level register fiddling.
You have the sources, get some decent static analysis tools and mine into it. Read back registers in working / non-working cases. Write code to unpack and decode them in a human readable fashion.
2023-05-15 12:18 PM
Did you find out the parameters of the receiving board?
In addition, in which line do you send the 'test message'?