iar &stm32调试过程中遇到的问题记录

10/16串口可以实现发送但是死或接受不了数据,前段时间还可以,但是不知道动了,不能入中断,后来加了增加几句关于标志位清除的函数后,可以进行接收数据了

 

1、串口都不能进入中断函数,造成HardFault_Hander,网上知道是由于不能进入中断造成的,需要添加中断向量,中断向量函数入口在启动文件startup_stm32f10x_hd_vl.s中,于是爸库里面的启动文件添加进来,但是报了天量的错误。一查,得知原来库里面的启动文件与IAR不兼容,于是在iar里面搜索“startup_stm32f1”的字样,找到文件里面D:\Program Files (x86)\IAR Systems\Embedded Workbench 8.1\arm\RTOS\SEGGER\ST\STM32F103\embOS_MB672\DeviceSupport的启动文件添加到iar。于是乎问题解决。花费了好久才解决。

CMSIS_Core.htm这个文件是什么鬼,也可以设置中断入口。

还有一种方法似乎也可以但是不理解:添加stm32f10x_vector.c

/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
* File Name          : stm32f10x_vector.c
* Author             : MCD Application Team
* Version            : V2.0.3
* Date               : 09/22/2008
* Description        : STM32F10x vector table for EWARM5.x toolchain.
*                      This module performs:
*                      - Set the initial SP
*                      - Set the initial PC == __iar_program_start,
*                      - Set the vector table entries with the exceptions ISR address,
*                      - Configure external SRAM mounted on STM3210E-EVAL board
*                       to be used as data memory (optional, to be enabled by user)
*                      After Reset the Cortex-M3 processor is in Thread mode,
*                      priority is Privileged, and the Stack is set to Main.
********************************************************************************
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/

/* Includes ------------------------------------------------------------------*/
#include "stm32f10x_lib.h"
#include "stm32f10x_it.h"

/* Private typedef -----------------------------------------------------------*/
typedef void( *intfunc )( void );
typedef union { intfunc __fun; void * __ptr; } intvec_elem;

/* Private define ------------------------------------------------------------*/
/* Uncomment the following line if you need to use external SRAM mounted on
   STM3210E-EVAL board as data memory */
/* #define DATA_IN_ExtSRAM */

/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/


#pragma language=extended
#pragma segment="CSTACK"

void __iar_program_start( void );

#pragma location = ".intvec"
/* STM32F10x Vector Table entries */
const intvec_elem __vector_table[] =
{
  { .__ptr = __sfe( "CSTACK" ) },
  __iar_program_start,
  NMIException,
  HardFaultException,
  MemManageException,
  BusFaultException,
  UsageFaultException,
  0, 0, 0, 0,            /* Reserved */ 
  SVCHandler,
  DebugMonitor,
  0,                      /* Reserved */
  PendSVC,
  SysTickHandler,
  WWDG_IRQHandler,
  PVD_IRQHandler,
  TAMPER_IRQHandler,
  RTC_IRQHandler,
  FLASH_IRQHandler,
  RCC_IRQHandler,
  EXTI0_IRQHandler,
  EXTI1_IRQHandler,
  EXTI2_IRQHandler,
  EXTI3_IRQHandler,
  EXTI4_IRQHandler,
  DMA1_Channel1_IRQHandler,
  DMA1_Channel2_IRQHandler,
  DMA1_Channel3_IRQHandler,
  DMA1_Channel4_IRQHandler,
  DMA1_Channel5_IRQHandler,
  DMA1_Channel6_IRQHandler,
  DMA1_Channel7_IRQHandler,
  ADC1_2_IRQHandler,
  USB_HP_CAN_TX_IRQHandler,
  USB_LP_CAN_RX0_IRQHandler,
  CAN_RX1_IRQHandler,
  CAN_SCE_IRQHandler,
  EXTI9_5_IRQHandler,
  TIM1_BRK_IRQHandler,
  TIM1_UP_IRQHandler,
  TIM1_TRG_COM_IRQHandler,
  TIM1_CC_IRQHandler,
  TIM2_IRQHandler,
  TIM3_IRQHandler,
  TIM4_IRQHandler,
  I2C1_EV_IRQHandler,
  I2C1_ER_IRQHandler,
  I2C2_EV_IRQHandler,
  I2C2_ER_IRQHandler,
  SPI1_IRQHandler,
  SPI2_IRQHandler,
  USART1_IRQHandler,
  USART2_IRQHandler,
  USART3_IRQHandler,
  EXTI15_10_IRQHandler,
  RTCAlarm_IRQHandler,
  USBWakeUp_IRQHandler,
  TIM8_BRK_IRQHandler,
  TIM8_UP_IRQHandler,
  TIM8_TRG_COM_IRQHandler,
  TIM8_CC_IRQHandler,
  ADC3_IRQHandler,
  FSMC_IRQHandler,
  SDIO_IRQHandler,
  TIM5_IRQHandler,
  SPI3_IRQHandler,
  UART4_IRQHandler,
  UART5_IRQHandler,
  TIM6_IRQHandler,
  TIM7_IRQHandler,
  DMA2_Channel1_IRQHandler,
  DMA2_Channel2_IRQHandler,
  DMA2_Channel3_IRQHandler,
  DMA2_Channel4_5_IRQHandler,
};

#ifdef DATA_IN_ExtSRAM
#pragma language=extended

__interwork int __low_level_init(void);

#pragma location="ICODE"
__interwork int __low_level_init(void)
{
   
/* FSMC Bank1 NOR/SRAM3 is used for the STM3210E-EVAL, if another Bank is 
  required, then adjust the Register Addresses*/

  /* Enable FSMC clock */
  *(vu32 *)0x40021014 = 0x00000114;
  
  /* Enable GPIOD, GPIOE, GPIOF and GPIOG clocks */  
  *(vu32 *)0x40021018 = 0x000001E0;
  
/* ---------------  SRAM Data lines, NOE and NWE configuration ---------------*/
/*----------------  SRAM Address lines configuration -------------------------*/
/*----------------  NOE and NWE configuration --------------------------------*/  
/*----------------  NE3 configuration ----------------------------------------*/
/*----------------  NBL0, NBL1 configuration ---------------------------------*/
  
  *(vu32 *)0x40011400 = 0x44BB44BB;
  *(vu32 *)0x40011404 = 0xBBBBBBBB;
  
  *(vu32 *)0x40011800 = 0xB44444BB;
  *(vu32 *)0x40011804 = 0xBBBBBBBB;
   
  *(vu32 *)0x40011C00 = 0x44BBBBBB;
  *(vu32 *)0x40011C04 = 0xBBBB4444;  

  *(vu32 *)0x40012000 = 0x44BBBBBB;
  *(vu32 *)0x40012004 = 0x44444B44;
  
/*----------------  FSMC Configuration ---------------------------------------*/  
/*----------------  Enable FSMC Bank1_SRAM Bank ------------------------------*/
  
  *(vu32 *)0xA0000010 = 0x00001011;
  *(vu32 *)0xA0000014 = 0x00000200;
  

  return (1);
}
#endif /*DATA_IN_ExtSRAM*/

/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/


 

开启了USART1的接收中断RXE,一旦发送数据就会进入HardFault_Handler,后来使用自带的历程就OK

HardFault_Handler出现的情况一般有两种: 
一种是:数组越界 
一种是:堆栈溢出,程序指针指飞

  最近在以前的项目上添加串口3通讯后,程序一进入接收中断后就产生HardFault_Hander。串口3发送数据一切正常,当打开串口3接收功能时,程序就处于HardFault_Hander状态,而导致死机。查询串口3的所有配置,都没有发现问题。在网上查询好久,也没有找到解答的办法。

  花了近二天时间后,突然发现项目的启动文件配置错误了。给配置为了startup_stm32f10x_ld.s。后打开startup_stm32f10x_ld.s文件查看,发现其中根本没有配置UARTS3的中断向量。

https://blog.csdn.net/lby1168/article/details/71617421

https://blog.csdn.net/hevake_lcj/article/details/6639750

 

 

 

Libraries里面的startup启动文件有些需要修改。我们使用之前的库(如F1、F2的库),这些库是使用老版本的IAR for ARM V5或V6版本编写的,在V7版本上使用这些库就不兼容,需要将text:CODE:REORDER改为text:CODE:NOROOT:REORDER

IAR Warning[Pe223]: function 'assert_param' declared implicitly 解决方法

添加定义  USE_STDPERIPH_DRIVER

 

 

使用F库里面的IAR工程yu'd遇到问题,下载调试时

iar &stm32调试过程中遇到的问题记录_第1张图片

解决步骤

iar &stm32调试过程中遇到的问题记录_第2张图片

iar &stm32调试过程中遇到的问题记录_第3张图片

 

老是遇到不能进入中断或者本来好好的,把别的中断打开就会影响另外一些中断之类的

本来串口打印调试信息用的挺好的,可是使用adc中断之后就不行了。串口打印不了,是不是打印的时候把adc先失能,然后再使能?

你可能感兴趣的:(ram)