啊啊 啊..今天真的好沮丧。调代码足足调了一晚上,不知道什么原因工程就是错,最后好不容易啊,在主函数加了个#include "stm32f10x_lib.h"就好使了,真不知道为什么。然后随即而来的又是一通打击,什么破串口调试助手啊,就是不给我出字啊,simulator都正确的额,到你那里就不正确,什么鬼啊。今天收获甚少,不开心啊.....我这一看时候不早了。。只好明天到实验室再弄一弄了
#include "stm32f10x_lib.h"
void Delay_MS(u16 dly)
{
u16 i, j;
for (i = 0; i < dly; i++)
for (j = 1000; j > 0; j--)
;
}
void RCC_Configuration(void);
void GPIO_Configuration(void);
void USART3_Configuration(void);
u8 tab[] = {"Flaergwe very sad today !!!"};
u8 i;
int main()
{
RCC_Configuration();
GPIO_Configuration();
USART3_Configuration();
for (i = 0; tab[i]; i++)
{
USART_SendData(USART3, tab[i]);
Delay_MS(100);
}
}
void RCC_Configuration()
{
RCC_DeInit();
RCC_HSEConfig(RCC_HSE_ON);
while (RCC_GetFlagStatus(RCC_FLAG_HSERDY) == RESET);
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
FLASH_SetLatency(FLASH_Latency_2);
RCC_HCLKConfig(RCC_SYSCLK_Div1);
RCC_PCLK2Config(RCC_HCLK_Div1);
RCC_PCLK1Config(RCC_HCLK_Div2);
RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);
RCC_PLLCmd(ENABLE);
while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET);
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
while (RCC_GetSYSCLKSource() != 0x08);
}
void GPIO_Configuration()
{
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_PinRemapConfig(GPIO_PartialRemap_USART3, ENABLE);
}
void USART3_Configuration()
{
USART_InitTypeDef U3;
U3.USART_BaudRate = 9600;
U3.USART_WordLength = USART_WordLength_8b;
U3.USART_StopBits = USART_StopBits_1;
U3.USART_Parity = USART_Parity_No;
U3.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
U3.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_Init(USART3, &U3);
USART_Cmd(USART3, ENABLE);
}