2024-10-03 06:34 AM - last edited on 2024-10-03 07:33 AM by Mike_ST
Hi, I'm pretty new to STM developement. I tried use "SubGhz Ping Pong" example in the cubeWL package, successfully. Now I search to establish a real com' between two STM32WL55JC1, where they can exchange data, etc... The different driver, API, layer make a real fog when you're a beginner. In differents manual theres no details on what do this function or this, and search in "radio_driver.c" is not very helpfull. Someone here can help me to understand how inplement and use those function ? Thank you very much.
Solved! Go to Solution.
2024-10-07 09:34 AM - edited 2024-10-07 09:37 AM
Hello @NightFury
I suggest you take a look at the implementation of send and receive on those two applications. Also, you can refer to this tutorial video and this application note AN5406 that may help you.
Best Regards.
STTwo-32
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-10-07 09:34 AM - edited 2024-10-07 09:37 AM
Hello @NightFury
I suggest you take a look at the implementation of send and receive on those two applications. Also, you can refer to this tutorial video and this application note AN5406 that may help you.
Best Regards.
STTwo-32
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-11-18 02:26 AM
Thanks for your reply. And sorry for the long response time I was working on something else...
So I take my time. My first attempt was to take an example in the WL package, and modify it.
(a little diagram of my project)
SMT32
| --> radio (subghz) P2P <-- (another STM32WL)
| --> USART1 to com with a nextion screen
| --> USART2 (standby, it may usefull)
| -- TIM2 (send data periodically)
With my 1st attempt, i was able to use radio, usart2. usart1, TIM2 and the debug st-link was'nt working
My 2nd attemt was to take all from zero, I build my own application (thanks for the help :) ) TIM2, USART2 (and debugger) is working well. But radio, is not working (i dont test usart1). I dont use the util sequencer for my apllication (not usefull, maybe later), maybe that's my problem ? i don't think radio can make a probem with TIMER or USART1...
So now my theorie for radio is I don't init the peripheral correctly, and i miss something. Why I think that ? Because Tx Timeout and Rx Timeout is not working (also Tx Done, and when i plug a board with a good program, it can receive any data). So this is my "subghz_phy_app.c" and "TIM2_IRQHandler" code :
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file subghz_phy_app.c
* @author MCD Application Team
* @brief Application of the SubGHz_Phy Middleware
******************************************************************************
* @attention
*
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "platform.h"
#include "sys_app.h"
#include "subghz_phy_app.h"
#include "radio.h"
/* USER CODE BEGIN Includes */
#include "usart.h"
/* USER CODE END Includes */
/* External variables ---------------------------------------------------------*/
/* USER CODE BEGIN EV */
/* USER CODE END EV */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
#define RF_FREQUENCY 868000000 /* Hz */
#define TX_OUTPUT_POWER 14 /* dBm */
#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 5 /* Symbols */
#define LORA_FIX_LENGTH_PAYLOAD_ON false
#define LORA_IQ_INVERSION_ON false
#define PAYLOAD_LEN 64
#define TX_TIMEOUT_VALUE 3000
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
/* Radio events function pointer */
static RadioEvents_t RadioEvents;
/* USER CODE BEGIN PV */
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
/*!
* @brief Function to be executed on Radio Tx Done event
*/
static void OnTxDone(void);
/**
* @brief Function to be executed on Radio Rx Done event
* @PAram payload ptr of buffer received
* @PAram size buffer size
* @PAram rssi
* @PAram LoraSnr_FskCfo
*/
static void OnRxDone(uint8_t *payload, uint16_t size, int16_t rssi, int8_t LoraSnr_FskCfo);
/**
* @brief Function executed on Radio Tx Timeout event
*/
static void OnTxTimeout(void);
/**
* @brief Function executed on Radio Rx Timeout event
*/
static void OnRxTimeout(void);
/**
* @brief Function executed on Radio Rx Error event
*/
static void OnRxError(void);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* Exported functions ---------------------------------------------------------*/
void SubghzApp_Init(void)
{
/* USER CODE BEGIN SubghzApp_Init_1 */
/* USER CODE END SubghzApp_Init_1 */
/* Radio initialization */
RadioEvents.TxDone = OnTxDone;
RadioEvents.RxDone = OnRxDone;
RadioEvents.TxTimeout = OnTxTimeout;
RadioEvents.RxTimeout = OnRxTimeout;
RadioEvents.RxError = OnRxError;
Radio.Init(&RadioEvents);
/* USER CODE BEGIN SubghzApp_Init_2 */
Radio.SetChannel(RF_FREQUENCY);
Radio.SetTxConfig(MODEM_LORA, TX_OUTPUT_POWER, 0, LORA_BANDWIDTH,
LORA_SPREADING_FACTOR, LORA_CODINGRATE,
LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON,
true, 0, 0, LORA_IQ_INVERSION_ON, TX_TIMEOUT_VALUE);
Radio.SetRxConfig(MODEM_LORA, LORA_BANDWIDTH, LORA_SPREADING_FACTOR,
LORA_CODINGRATE, 0, LORA_PREAMBLE_LENGTH,
LORA_SYMBOL_TIMEOUT, LORA_FIX_LENGTH_PAYLOAD_ON,
0, true, 0, 0, LORA_IQ_INVERSION_ON, true);
Radio.SetMaxPayloadLength(MODEM_LORA, PAYLOAD_LEN);
Radio.Rx(RX_TIMEOUT_VALUE);
/* USER CODE END SubghzApp_Init_2 */
}
/* USER CODE BEGIN EF */
/* USER CODE END EF */
/* Private functions ---------------------------------------------------------*/
static void OnTxDone(void)
{
/* USER CODE BEGIN OnTxDone */
HAL_UART_Transmit(&huart2, (uint8_t *)"TxDone\r\n", 8, 1000);
/* USER CODE END OnTxDone */
}
static void OnRxDone(uint8_t *payload, uint16_t size, int16_t rssi, int8_t LoraSnr_FskCfo)
{
/* USER CODE BEGIN OnRxDone */
HAL_UART_Transmit(&huart2, (uint8_t *)"RxDone\r\n", 8, 1000);
/* USER CODE END OnRxDone */
}
static void OnTxTimeout(void)
{
/* USER CODE BEGIN OnTxTimeout */
HAL_UART_Transmit(&huart2, (uint8_t *)"TxTimeout\r\n", 11, 1000);
/* USER CODE END OnTxTimeout */
}
static void OnRxTimeout(void)
{
/* USER CODE BEGIN OnRxTimeout */
HAL_UART_Transmit(&huart2, (uint8_t *)"RxTimeout\r\n", 11, 1000);
/* USER CODE END OnRxTimeout */
}
static void OnRxError(void)
{
/* USER CODE BEGIN OnRxError */
HAL_UART_Transmit(&huart2, (uint8_t *)"RxError\r\n", 9, 1000);
/* USER CODE END OnRxError */
}
/* USER CODE BEGIN PrFD */
/* USER CODE END PrFD */
void TIM2_IRQHandler(void)
{
/* USER IRQ CODE BEGIN */
isMaster = (GPIOC->IDR & 14);
if (!isMaster)
{
Radio.Rx(3000);
} else
{
HAL_Delay(Radio.GetWakeupTime());
HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin);
HAL_UART_Transmit(&huart2, (uint8_t *)"IRQ Tx\r\n", 8, 1000);
radio_status_t status = Radio.Send((uint8_t *)"Test", 64);
if(status == (radio_status_t)"OK")
{
HAL_UART_Transmit(&huart2, (uint8_t *)"OK Tx\r\n", 7, 1000);
} else if (status == (radio_status_t)"ERROR")
{
HAL_UART_Transmit(&huart2, (uint8_t *)"ERROR Tx\r\n", 10, 1000);
} else
{
HAL_UART_Transmit(&huart2, (uint8_t *)"NONE Tx\r\n", 9, 1000);
}
}
/* USER IRQ CODE END */
//reset the interrupt flag
TIM2->SR = (0 << 0);
}
NB : thanks a lot for your help, and sorry for my bad english
2024-11-18 04:47 AM
Hello @NightFury
This is an old thread. I suggest you select as best answer the post that answer your first request. And then, Create a new one for this new request (with more details and description if possible).
Best Regards.
STTwo-32
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.