2024-11-18 06:02 AM
Hello, sorry to waste your time, but I don't understand. I use a NUCLEO-WL55JC1, after some test with the example in the WL_Package, and some errors to adaptate the example code. I have undertaken to start from zero. I use the example code in the Mono Core Ping Pong example, but I don't use the sequencer (not very usefull in my case). So :
I wan't to send data every x seconds, for this I use TIM2. In the TIM_IRQ I have to toggle pin (work) and send data (don't work). To test if I can send data, I check if I have "TxDone" or "TxTimeout" (nope) and I use a 2nd WL55C1 with a working code in Rx mode to check if I receive something (nope). So clearly :
TIM2 -> Working
Radio -> Not working
USART2 -> Working
USART1 -> Not implemented
I check multiple times my init of subghz, and I think I have all I need. I upload the "subghz_phy_app" and "TIM2_IRQHandler" code. Clearly I miss something, but what ? I already check if I call "subghz_init" and yes. Can you help me pls ?
void TIM2_IRQHandler(void)
{
/* USER IRQ CODE BEGIN */
isMaster = ((GPIOC->IDR >> 4) & 1);
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);
}
/* 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 */
2024-11-26 01:53 AM
Hello @NightFury
I suggest you take a look at the STM32WL-SubGHz-PhyBasic-Tx-Rx examples and add the additional interfaces that you want to use (USART...). If that works fine, you can try to reformulate eliminating the sequencer (I don't recommend that).
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.