ourdev上发了没人回...
从上午一直折腾到现在..串口调试助手就是收不到数据...
开发版用英蓓特给的例程编译调试是可以正常发送数据的,可是上了我自己的程序就不行,不知道为什么TAT..
在这个程序要实现的功能是 每隔一段一段时间发0xa4到PC那,用的是V3.0的固件库(例程用的是2.0)
具体现象是,程序能正常运行,串口调试助手没有收到数据,但调试助手每次关闭->开启一次串口都会收到一个0x00,什么波特率下都会收到
大家帮帮看看为什么吧..我基本是一个字一个字跟搜到的例程对过了..可是就是发不出数据..
main.c文件内容如下:
#include "stm32f10x.h"
#include "misc.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
GPIO_InitTypeDef GPIO_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;
/* Private function prototypes -----------------------------------------------*/
void RCC_Configuration(void);
void Delay(__IO uint32_t nCount);
void NVIC_Configuration(void);
void GPIO_Configuration(void);
void EXTI_Configuration(void);
void USART_Configuration(void);
/* Private function ----------------------------------------------------------*/
int main(void)
{
RCC_Configuration();
NVIC_Configuration();
GPIO_Configuration();
EXTI_Configuration();
USART_Configuration();
while (1)
{
USART_SendData(USART1, (u8) 0xa4);
while(USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET)
{
}
Delay(0xaffff);
}
}
/*-----------------------------------------------------------------------
RCC配置函数,包括各个外设时钟的开启
-----------------------------------------------------------------------*/
void RCC_Configuration(void)
{
SystemInit();
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_USART1, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
}
/*-----------------------------------------------------------------------
NVIC配置函数
此为模板
-----------------------------------------------------------------------*/
void NVIC_Configuration(void)
{
#ifdef VECT_TAB_RAM
/* Set the Vector Table base location at 0x20000000 */
NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0);
#else /* VECT_TAB_FLASH */
/* Set the Vector Table base location at 0x08000000 */
NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);
#endif
}
/*-----------------------------------------------------------------------
GPIO配置函数
此为模板
-----------------------------------------------------------------------*/
void GPIO_Configuration(void)
{
/*TX在PA9,配置为推挽*/
GPIO_XXXXXXXXXXXXXXXXIO_Pin = GPIO_Pin_9;
GPIO_XXXXXXXXXXXXXXXXIO_Mode = GPIO_Mode_Out_PP;
GPIO_XXXXXXXXXXXXXXXXIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/*RX在PA10,配置为浮空[s:9]A8为发送按钮,配置为浮空*/
GPIO_XXXXXXXXXXXXXXXXIO_Pin =GPIO_Pin_8 | GPIO_Pin_10;
GPIO_XXXXXXXXXXXXXXXXIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA,&GPIO_InitStructure);
}
/*-----------------------------------------------------------------------
EXTI配置函数,对应GPIO端口与中断线的链接也在这里
此为模板
-----------------------------------------------------------------------*/
void EXTI_Configuration(void)
{
}
/*-----------------------------------------------------------------------
USART配置
-----------------------------------------------------------------------*/
void USART_Configuration(void)
{
USART_InitTypeDef USART_InitStructure;
USART_ClockInitTypeDef USART_ClockInitStructure;
USART_XXXXXXXXXXXXXXXXART_BaudRate = 115200;
USART_XXXXXXXXXXXXXXXXART_WordLength = USART_WordLength_8b;
USART_XXXXXXXXXXXXXXXXART_StopBits = USART_StopBits_1;
USART_XXXXXXXXXXXXXXXXART_Parity = USART_Parity_No;
USART_XXXXXXXXXXXXXXXXART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_XXXXXXXXXXXXXXXXART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_XXXXXXXXXXXXXXXXXXXXXART_Clock = USART_Clock_Disable;
USART_XXXXXXXXXXXXXXXXXXXXXART_CPOL = USART_CPOL_Low;
USART_XXXXXXXXXXXXXXXXXXXXXART_CPHA = USART_CPHA_2Edge;
USART_XXXXXXXXXXXXXXXXXXXXXART_LastBit = USART_LastBit_Disable;
USART_ClockInit(USART1,&USART_ClockInitStructure);
USART_Init(USART1,&USART_InitStructure);
USART_Cmd(USART1,ENABLE);
}
/*-----------------------------------------------------------------------
延时函数
-----------------------------------------------------------------------*/
void Delay(__IO uint32_t nCount)
{
for(; nCount != 0; nCount--);
}
/*-----------------------------------------------------------------------
assert
-----------------------------------------------------------------------*/
#ifdef USE_FULL_ASSERT
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****/
200字以内,仅用于支线交流,主线讨论请采用回复功能。