cancel
Showing results for 
Search instead for 
Did you mean: 

How to use the FP-SNS-MOTENVWB1 with STM32CubeIDE?

Romain1
Associate III

The archive downloaded here contains projects for various IDEs, including the STM32CubeIDE.

https://www.st.com/content/st_com/en/products/embedded-software/mcu-mpu-embedded-software/stm32-embedded-software/stm32-ode-function-pack-sw/fp-sns-motenvwb1.html

The project compiles and runs fine with the P-Nucleo-WB55 and the X-NUCLEO-IKS01A3 sensor shield.

When trying to add a timer in the Cube configuration, it throws off the files in the project, creates duplicates and the project does not compile anymore.

  1. Am I using the STM32CubeIDE correctly? Should I be using the CubeMX instead?
  2. Why does the Project Explorer folder structure is totally different than the file system structure?

Using STM32CubeIDE 1.1.0 on a Windows 10 machine.

Thanks

5 REPLIES 5
Romain1
Associate III

The STM32CubeMX version 5.4.0 gives better results.

The issue with the compilation is caused by the generated file Projects\P-NUCLEO-WB55.Nucleo\Applications\MOTENV1\Core\Inc\hw_if.h

This file's content is almost identical to this file Middlewares\ST\STM32_WPAN\interface\patterns\ble_thread\hw.h

Hence, the compiler sees the same definition twice and exits.

Commenting app_conf.h:26 #include "hw_if.h" prevents the inclusion of the duplicate definitions and solve the issue.

The last problem is that each time the project us re-generated with the CubeMX, this modification is lost. Can this be fixed in the CubeMX?

Remi QUINTIN
ST Employee

In fact all user modifications have to be surrounded by comments like /* USER CODE BEGIN *** */ and /* USER CODE END *** */ so that the code generator will not get rid of your changes. The code generator is reloading all files which are not expected to be modified by a user from the internal repository, hence overwriting any changes you would have made in them.

For exemple in main.c file, you can find:

/* Private includes ----------------------------------------------------------*/

/* USER CODE BEGIN Includes */

#include "stm32_lpm.h"

#include "stm32_seq.h"

#include "dbg_trace.h"

#include "hw_conf.h"

#include "otp.h"

/* USER CODE END Includes */

So I would recommend to insert in this protected area above a #define __HW_H so that is would not include this file again in that project.

Romain1
Associate III

The beginning of the file does not contain a protected section:

/**
 ******************************************************************************
  * File Name          : app_conf.h
  * Description        : Application configuration file for STM32WPAN Middleware.
  *
 ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
  * All rights reserved.</center></h2>
  *
  * This software component is licensed by ST under Ultimate Liberty license
  * SLA0044, the "License"; You may not use this file except in compliance with
  * the License. You may obtain a copy of the License at:
  *                             www.st.com/SLA0044
  *
  ******************************************************************************
  */
 
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef APP_CONF_H
#define APP_CONF_H
 
#include "hw.h"
#include "hw_conf.h"
#include "hw_if.h"
 
/******************************************************************************
 * Application Config
 ******************************************************************************/
 
/**< generic parameters ******************************************************/
 
/**
 * Define Tx Power
 */   
#define CFG_TX_POWER                      (0x18) /**< 0dbm */

The Middlewares\ST\STM32_WPAN\interface\patterns\ble_thread\hw.h is provided by the package and is not generated by the CubeMX.

I have thought about modifying this file instead, but it is included by 3 source files and I'm afraid of introducing regressions in the Middleware/BLE.

Versions:

FP-SNS-MOTENVWB1 1.0.0

STM32CubeIDE 1.1.0

STM32CubeMX 5.4.0

Remi QUINTIN
ST Employee

Strange! I don’t understand why the code generator is creating this hw_if.h file as it is so similar to the hw.h file coming from the original FW repository.

It is quite possibly a configuration issue where the path to some files are not defined properly.

Anyhow, you should try to modify the app_conf.h file to remove this include. Keep this file aside before regenerating this code. Then re-install it before the compilation.

Romain1
Associate III

The final solution for me was to use the recursive inclusion prevention define to automatically exclude the content of that file by adding -DHW_IF_H to the compiler definitions. This way I didn't have to edit app_conf.h after each STM32CubeMX regeneration.

Steps:

Go to the project properties

C/C++Build - Settings

MCU GCC C Compiler - Preprocessor

Add HW_IF_H in the Define symbols list:

0690X00000AqYhSQAV.png

Second thing I realized after enabling the UART1, the peripheral initialization call is not added in the main, unlike everything else. is there a good reason for that?

See below, I had to add the call in the user code section for the UART to work:

int main(void)
{
  /* USER CODE BEGIN 1 */
 
  /* USER CODE END 1 */
  
 
  /* MCU Configuration--------------------------------------------------------*/
 
  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();
 
  /* USER CODE BEGIN Init */
 
  /* USER CODE END Init */
 
  /* Configure the system clock */
  SystemClock_Config();
 
  /* USER CODE BEGIN SysInit */
 
  /* USER CODE END SysInit */
 
 /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_DMA_Init();
  MX_RF_Init();
  MX_RTC_Init();
  MX_CRC_Init();
  MX_TIM1_Init();
  MX_ADC1_Init();
  MX_TIM2_Init();
  /* USER CODE BEGIN 2 */
  MX_USART1_UART_Init();
   /* USER CODE END 2 */
 
  /* Init code for STM32_WPAN */  
  APPE_Init();