天堂鸟x1 发表于 2016-4-30 17:32:34

STM32CubeMX生成的代码在Keil5ARM中报错!

每次在STM32CubeMX生成Keil5的代码,用Keil5打开后,编译过程中报错:
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c(137): error:#1113: Inline assembler not permitted when generating Thumb code

具体错误在:
/* Private functions ---------------------------------------------------------*/
__NOINLINE
static void PWR_OverloadWfe(void)
{
__asm volatile( "wfe" );
__asm volatile( "nop" );
}
当我将这2行注释掉后,系统能够从新编译,并能够正常运行!

请问:
1、这2句是什么意思,注释掉会不会有问题?(本人新人一个,还望大神详细解释)
2、有没有办法或哪里设置,将这里处理掉?

watershade 发表于 2016-5-1 13:17:23

我的没有遇到过这种问题,请问你怎么配置的。可以穿一下配置文件

天堂鸟x1 发表于 2016-5-3 10:10:53

我是在STM32CubeMX中生成的项目程序,使用STM32F103C8T8芯片,配合使用Firmware 1.3.1,Keil系统使用的是uVision V5.11,配的是对应编程模块。无论我陪什么样的设置,都提示这个错误,只有注释掉这2句,就能够使用!
附上原始生成的代码
/**
******************************************************************************
* @file    stm32f1xx_hal_pwr.c
* @authorMCD Application Team
* @version V1.0.3
* @date    11-January-2016
* @brief   PWR HAL module driver.
*
*          This file provides firmware functions to manage the following
*          functionalities of the Power Controller (PWR) peripheral:
*         + Initialization/de-initialization functions
*         + Peripheral Control functions
*
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*   1. Redistributions of source code must retain the above copyright notice,
*      this list of conditions and the following disclaimer.
*   2. Redistributions in binary form must reproduce the above copyright notice,
*      this list of conditions and the following disclaimer in the documentation
*      and/or other materials provided with the distribution.
*   3. Neither the name of STMicroelectronics nor the names of its contributors
*      may be used to endorse or promote products derived from this software
*      without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************
*/

/* Includes ------------------------------------------------------------------*/
#include "stm32f1xx_hal.h"

/** @addtogroup STM32F1xx_HAL_Driver
* @{
*/

/** @defgroup PWR PWR
* @brief    PWR HAL module driver
* @{
*/

#ifdef HAL_PWR_MODULE_ENABLED

/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/

/** @defgroup PWR_Private_Constants PWR Private Constants
* @{
*/

/** @defgroup PWR_PVD_Mode_Mask PWR PVD Mode Mask
* @{
*/
#define PVD_MODE_IT               ((uint32_t)0x00010000)
#define PVD_MODE_EVT            ((uint32_t)0x00020000)
#define PVD_RISING_EDGE         ((uint32_t)0x00000001)
#define PVD_FALLING_EDGE          ((uint32_t)0x00000002)
/**
* @}
*/


/** @defgroup PWR_register_alias_address PWR Register alias address
* @{
*/
/* ------------- PWR registers bit address in the alias region ---------------*/
#define PWR_OFFSET               (PWR_BASE - PERIPH_BASE)
#define PWR_CR_OFFSET            0x00
#define PWR_CSR_OFFSET         0x04
#define PWR_CR_OFFSET_BB         (PWR_OFFSET + PWR_CR_OFFSET)
#define PWR_CSR_OFFSET_BB      (PWR_OFFSET + PWR_CSR_OFFSET)
/**
* @}
*/
   
/** @defgroup PWR_CR_register_alias PWR CR Register alias address
* @{
*/
/* --- CR Register ---*/
/* Alias word address of LPSDSR bit */
#define LPSDSR_BIT_NUMBER      POSITION_VAL(PWR_CR_LPDS)
#define CR_LPSDSR_BB             ((uint32_t)(PERIPH_BB_BASE + (PWR_CR_OFFSET_BB * 32) + (LPSDSR_BIT_NUMBER * 4)))

/* Alias word address of DBP bit */
#define DBP_BIT_NUMBER            POSITION_VAL(PWR_CR_DBP)
#define CR_DBP_BB                ((uint32_t)(PERIPH_BB_BASE + (PWR_CR_OFFSET_BB * 32) + (DBP_BIT_NUMBER * 4)))

/* Alias word address of PVDE bit */
#define PVDE_BIT_NUMBER         POSITION_VAL(PWR_CR_PVDE)
#define CR_PVDE_BB               ((uint32_t)(PERIPH_BB_BASE + (PWR_CR_OFFSET_BB * 32) + (PVDE_BIT_NUMBER * 4)))

/**
* @}
*/

/** @defgroup PWR_CSR_register_alias PWR CSR Register alias address
* @{
*/

/* --- CSR Register ---*/
/* Alias word address of EWUP1 bit */
#define CSR_EWUP_BB(VAL)         ((uint32_t)(PERIPH_BB_BASE + (PWR_CSR_OFFSET_BB * 32) + (POSITION_VAL(VAL) * 4)))
/**
* @}
*/

/**
* @}
*/

/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/** @defgroup PWR_Private_Functions PWR Private Functions
* brief   WFE cortex command overloaded for HAL_PWR_EnterSTOPMode usage only (see Workaround section)
* @{
*/
static void PWR_OverloadWfe(void);

/* Private functions ---------------------------------------------------------*/
__NOINLINE
static void PWR_OverloadWfe(void)
{
__asm volatile( "wfe" );                // 这个地方提示报错
__asm volatile( "nop" );               // 这个地方提示报错
}

发表于 2016-5-3 11:46:46

汇编指令,
WFI(Wait for interrupt)和WFE(Wait for event)是两个让ARM核进入low-power standby模式的指令,由ARM architecture定义,由ARM core实现。
NOP 就是空指令。
页: [1]
查看完整版本: STM32CubeMX生成的代码在Keil5ARM中报错!