stm32程序下载后不能运行
发布: 2010-2-08 17:03 | 作者: jawjy | 来源: StmFans思蜕盟 OPELC 自由电子联盟
写了一个简单的闪灯程序,用的是MDK4.01,软件仿真正常,下载到板子上可以运行,断一下电就运行不了.
板子没有问题,boot设置也对的,烧其他程序都正常.
到底怎么回事?
我怀疑是在MDK4.01设置不对!
谁遇到过这样的问题?请高手帮忙分析一下!!!!!!!!!!!!!!!!!
板子没有问题,boot设置也对的,烧其他程序都正常.
到底怎么回事?
我怀疑是在MDK4.01设置不对!
谁遇到过这样的问题?请高手帮忙分析一下!!!!!!!!!!!!!!!!!

下面是main.c程序,固件库是最新的!
麻烦帮忙看看,谢谢了!
/* 头文件包含 ---------------------------------------------------------------*/
#include "stm32f10x.h"
/** @addtogroup STM32F10x_StdPeriph_Examples
* @{
*/
/** @addtogroup GPIO_IOToggle
* @{
*/
/* Private typedef (定义类型)-------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro (宏定义)-----------------------------------------------------*/
/* Private variables(变量定义)------------------------------------------------*/
GPIO_InitTypeDef GPIO_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;
int Key1=0;
int Key2=0;
/* Private function prototypes (函数声明)-------------------------------------*/
void RCC_Configuration(void);
void GPIO_Configuration(void);
void EXTI_Configuration(void);
void EXTI3_IRQHandler(void);
void Delay(__IO uint32_t nCount);
/* Private functions (函数) --------------------------------------------------*/
/**
* @brief Main program.
* @param None
* @retval None
*/
void main(void)
{
/* System Clocks Configuration (系统时钟配置) */
RCC_Configuration();
/* GPIO Configuration (GPIO配置) */
GPIO_Configuration();
/* EXTI Configuration (EXTI配置) */
EXTI_Configuration();
/*使能或者失能APB2外设时钟*/
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA |
RCC_APB2Periph_AFIO,
ENABLE);//使能功能复用IO时钟和GPIOA时钟
while (1)
{ if(Key1==1&&Key2==0)
{
/* Turn on LD2 */
GPIO_SetBits(GPIOA, GPIO_Pin_1);
/* Insert delay */
Delay(0xAFFFF);
Delay(0xAFFFF);
/* Turn off LD2 */
GPIO_ResetBits(GPIOA, GPIO_Pin_1);
/* Insert delay */
Delay(0xAFFFF);
Delay(0xAFFFF);
}
else if(Key1==0&&Key2==1)
{/* Turn on LD1 */
GPIO_SetBits(GPIOA, GPIO_Pin_0);
/* Insert delay */
Delay(0xAFFFF);
Delay(0xAFFFF);
/* Turn off LD1 */
GPIO_ResetBits(GPIOA, GPIO_Pin_0);
/* Insert delay */
Delay(0xAFFFF);
Delay(0xAFFFF);
}
else
{/* Turn on LD1 */
GPIO_SetBits(GPIOA, GPIO_Pin_0);
/* Insert delay */
Delay(0xAFFFF);
Delay(0xAFFFF);
/* Turn on LD2 */
GPIO_SetBits(GPIOA, GPIO_Pin_1);
/* Insert delay */
Delay(0xAFFFF);
Delay(0xAFFFF);
/* Turn off LD1 */
GPIO_ResetBits(GPIOA, GPIO_Pin_0);
/* Insert delay */
Delay(0xAFFFF);
Delay(0xAFFFF);
/* Turn off LD2 */
GPIO_ResetBits(GPIOA, GPIO_Pin_1);
/* Insert delay */
Delay(0xAFFFF);
Delay(0xAFFFF);
}
EXTI3_IRQHandler();
}
}
/**
* @brief System Clocks Configuration (系统时钟配置).
* @param None
* @retval None
*/
void RCC_Configuration(void)
{
/* Setup the microcontroller system. Initialize the Embedded Flash Interface,
initialize the PLL and update the SystemFrequency variable. */
SystemInit();
}
/**
* @brief GPIO Configuration (GPIO配置).
* @param None
* @retval None
*/
void GPIO_Configuration(void)
{
/*根据GPIO_InitStruct中指定的参数初始化外设GPIOx寄存器 */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1;//选择待设置的GPIO管脚
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;//设置选中管脚的速率
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;//设置选中管脚的工作状态
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_8;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/*选择GPIO管脚用作外部中断线路*/
GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource3|GPIO_PinSource8);
}
/**
* @brief EXTI Configuration (EXTI配置)).
* @param None
* @retval None
*/
void EXTI_Configuration(void)
{
/*根据EXTI_InitStruct中指定的参数初始化外设EXTI寄存器 */
EXTI_InitStructure.EXTI_Line = EXTI_Line3|EXTI_Line8;//选择外部线路(0--18)
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;//设置线路的模式
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;//设置线路的触发边沿
EXTI_InitStructure.EXTI_LineCmd = ENABLE;//定义选中线路的新状态
EXTI_Init(&EXTI_InitStructure);
}
/**
* @brief Key In.
* @param None
* @retval None
*/
void EXTI3_IRQHandler(void)
{
if(EXTI_GetITStatus(EXTI_Line3)!= RESET)
{
Key1=1;
Key2=0;
/* Clear the EXTI line 3 pending bit */
EXTI_ClearITPendingBit(EXTI_Line3);
}
if(EXTI_GetITStatus(EXTI_Line8)!= RESET)
{
Key1=0;
Key2=1;
/* Clear the EXTI line 3 pending bit */
EXTI_ClearITPendingBit(EXTI_Line8);
}
}
/**
* @brief Inserts a delay time.
* @param nCount: specifies the delay time length.
* @retval None
*/
void Delay(__IO uint32_t nCount)
{
for(; nCount != 0; nCount--);
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t* file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* Infinite loop */
while (1)
{
}
}
#endif
/**
* @}
*/
/**
* @}
*/
/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/
你好,我把ev board 上usart(rs232)port上的2、3脚短路后在我的终端机上可以看到显示的字了!请问这是什么问题呢?
http://docs.google.com/leaf?id=0 ... xZTg5ZmYy&hl=en
我把程式放在這裡..
真的很謝謝你這樣子幫我 真的很謝謝,目前看到終端機有字串就好高興…雖然說是短路才有…希望可以完全解決^^
并没有什么jumper要接
但pc端应该也不会有什么问题啊..这中间...一定要把2、3pin短路才可以通这个是算他自己跟自己说收到了?
请问你有碰过这样的情形吗?
我的STM32要送的数据就是AD读到的值,然后经由RS232送给计算机的终端机显示!(2、3pin短路他就真的写出我目前AD读到的值了,随时调整VR在终端机上都有马上改变读到的值)一没短路,终端机就接收不到信号了..这样看起来是STM32自发自收然后计算机怎么会显示出值来呢?
因为这样子看起来像是STM32自发自收又加上终端机收到讯号显示出来!?
那我希望PIN2、3不短路又能在终端机显示的话目前看起来我不知该从何下手!!
因为软件 硬件看起来都没有错,计算机终端机设定看起来也是正确的!
哈哈 还麻烦你这样帮我debug一天结果是乌龙一场…
说实话,对于232的头(2、3短接头),一不小心就会短错了,一般我手上都长期备着两只2、3脚短接好的公/母头,在需要时直接用它们插上去就可以了。
现在把工程文件发上来,请帮我分析分析!
(2010-03-02 16:20:25, Size: 1.02 MB, Downloads: 2)