使用HAL库出现No Cortex-M SW Device Found

使用STM32CubeMX生成代码下载到STM32F103c8,再次下载时出现No Cortex-M SW Device Found,原因是在void HAL_MspInit(void)函数中关闭了JTAG功能

    /**DISABLE: JTAG-DP Disabled and SW-DP Disabled 
    */
  __HAL_AFIO_REMAP_SWJ_DISABLE();

删除    __HAL_AFIO_REMAP_SWJ_DISABLE();即可。


### STM32 USB Peripheral Programming and Configuration For configuring and programming the USB peripheral on an STM32 microcontroller, developers can utilize a variety of Integrated Development Environments (IDEs), with over 20 options available including commercial versions like MDK-ARM-STM32 and IAR-EWARM as well as free alternatives such as SW4STM32, TrueSTUDIO, and CoIDE[^1]. The official recommendation from ST is to use STM32CubeMX for initial project setup; this tool allows visual configuration of chip resources and pins before generating source code that can be imported into any chosen IDE. The process typically involves several key steps: #### Setting Up the Project Using STM32CubeMX Before writing custom USB application code, it's beneficial to set up the basic framework using STM32CubeMX. This includes selecting the appropriate device model, enabling necessary peripherals (including USB), setting system clock configurations, and choosing middleware components required by the specific USB class being implemented. Once these settings are configured within STM32CubeMX, exporting the generated files will produce a ready-to-use template compatible with selected IDE environments. #### Writing Application Code Based on HAL Library When developing applications based on the Hardware Abstraction Layer (HAL) library provided by STMicroelectronics, data types defined according to C99 standards should be used consistently throughout all modules—such as `uint32_t` or `int16_t`, which ensure portability across different platforms while maintaining type safety during compilation time checks[^2]. To interact directly with hardware registers associated with the USB interface when needed outside higher-level APIs offered through HAL functions, one might also refer to definitions found in header files included under the CMSIS-Core package installed alongside other dependencies managed via CubeMX-generated projects. #### Configuring Memory Protection Unit (MPU) In some cases where enhanced security features need implementation around critical sections handling sensitive information exchanged over USB connections, configuring MPU regions could become relevant. Parameters controlling whether certain memory areas have access restrictions applied would look similar to what has been documented elsewhere regarding Cortex-M series processors' architecture specifications[^3]: ```c #define MPU_REGION_ENABLE ((uint8_t)0x01) #define MPU_REGION_DISABLE ((uint8_t)0x00) ``` These macros define constants representing enabled/disabled states applicable not only specifically towards USB operations but generally whenever fine-grained control over protected segments becomes important inside embedded systems built upon ARM cores supporting MPU functionality. --related questions-- 1. How does one choose between various supported IDEs for STM32 development? 2. What advantages do commercial IDEs offer compared to their open-source counterparts? 3. Can you provide examples demonstrating how to implement common USB classes using HAL libraries? 4. Are there best practices recommended for integrating third-party drivers into STM32 projects initialized through STM32CubeMX?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值