2019-10-15 07:32 AM
The archive downloaded here contains projects for various IDEs, including the STM32CubeIDE.
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.
Using STM32CubeIDE 1.1.0 on a Windows 10 machine.
Thanks
2019-10-15 11:57 AM
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?
2019-10-16 09:09 AM
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.
2019-10-17 03:21 AM
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>© 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
2019-10-17 07:48 AM
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.
2019-10-18 08:20 AM
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:
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();