int main(void)
{
#ifdef DEBUG
debug();
#endif
u8 i,data;
RCC_configuration();
GPIO_Configuration();
USART_Configuration();
data='A';
for(i=0;i<30;i++)
{
USART_SendData(USART1,data);
data++;
while(USART_GetFlagStatus (USART1,USART_FLAG_TC)==RESET);
}
}
void USART_Configuration (void)
{
USART_InitTypeDef USART_InitStructure;
USART_InitStructure.USART_BaudRate=9600;
USART_InitStructure.USART_WordLength=USART_WordLength_8b;
USART_InitStructure.USART_StopBits=USART_StopBits_1;
USART_InitStructure.USART_Parity=USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl=USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode=USART_Mode_Tx | USART_Mode_Rx;
USART_Init(USART1,&USART_InitStructure);
USART_Cmd(USART1,ENABLE);
}
void RCC_configuration(void)
{
RCC_DeInit(); //3õê¼»ˉÎaè±ê¡Öμ
RCC_HSEConfig(RCC_HSE_ON); //ê1Äüía2¿μĸßËùê±Öó
while (RCC_GetFlagStatus(RCC_FLAG_HSERDY)==RESET); //μè′yía2¿¸ßËùê±Öóê1Äü¾íD÷
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable); //Enable Prefetch Buffer
FLASH_SetLatency(FLASH_Latency_2); //Flash 2 wait state
RCC_HCLKConfig(RCC_SYSCLK_Div1); //HCLK=SYSCLK
RCC_PCLK2Config(RCC_HCLK_Div1); //PCLK2=HCLK
RCC_PCLK2Config(RCC_HCLK_Div2); //PCLK1=HCLK/2
RCC_PLLConfig(RCC_PLLSource_HSE_Div1,RCC_PLLMul_9); //PLLCLK=8MHZ*9=72MHZ
RCC_PLLCmd(ENABLE); //Enable PLLCLK
while (RCC_GetFlagStatus(RCC_FLAG_HSERDY)==RESET); //wait till PLLCLK is ready
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK); //Select PLL as system clock
while (RCC_GetSYSCLKSource()!=0x08); //Wait till PLL is used as system clock source
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE); //ê1ÄüAPB2íaéèμÄGPIOAμÄê±Öó
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE); //ê1ÄüAPB2íaéèμÄGPIOCμÄê±Öó
}
void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_9;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF_PP;
GPIO_Init(GPIOA,&GPIO_InitStructure);
/* Configure USARTx_Tx as alternate function push-pull*/
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_10;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA,&GPIO_InitStructure);
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
是否应该令data等于A的ASC码值呢?
一周热门 更多>