我用官网上的示例程序为什么一直没有哦数据?程序如下:
int main(void)
{
SysTick_Configuration(); //这个函数官网上没有写,我加上的
/* NVIC configuration */
NVIC_Configurationuration();
/* Enable GPIOA clock */
RCC_AHBPeriphClock_Enable( RCC_AHBPERIPH_GPIOA , ENABLE );
/* Enable USART1 APB clock */
RCC_APB2PeriphClock_Enable( RCC_APB2PERIPH_USART1 , ENABLE );
/* USART1 Pins configuration **************************************************/
GPIO_DeInit( GPIOA );
{
/* Configure the GPIO ports */
GPIO_InitPara GPIO_InitStructure;
/* Connect pin to Periph */
GPIO_PinAFConfig( GPIOA , GPIO_PINSOURCE9, GPIO_AF_1 );
GPIO_PinAFConfig( GPIOA , GPIO_PINSOURCE10, GPIO_AF_1 );
/* Configure pins as AF pushpull */
GPIO_InitStructure.GPIO_Pin = GPIO_PIN_9 | GPIO_PIN_10;
GPIO_InitStructure.GPIO_Mode = GPIO_MODE_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_SPEED_50MHZ;
GPIO_InitStructure.GPIO_OType = GPIO_OTYPE_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PUPD_NOPULL;
GPIO_Init( GPIOA , &GPIO_InitStructure);
}
{
USART_InitPara USART_InitStructure;
USART_DeInit( USART1 );
USART_InitStructure.USART_BRR = 115200;
USART_InitStructure.USART_WL = USART_WL_8B;
USART_InitStructure.USART_STBits = USART_STBITS_1;
USART_InitStructure.USART_Parity = USART_PARITY_RESET;
USART_InitStructure.USART_HardwareFlowControl = USART_HARDWAREFLOWCONTROL_NONE;
USART_InitStructure.USART_RxorTx = USART_RXORTX_RX | USART_RXORTX_TX;
USART_Init(USART1, &USART_InitStructure);
}
USART_Enable(USART1, ENABLE);
/* Enable the USART1 Transmoit interrupt: this interrupt is generated when the
USART1 transmit data register is empty */
USART_INT_Set(USART1, USART_INT_TBE, ENABLE);
/* Wait until USART1 send the TxBuffer */
while(TxCount < NbrOfDataToTransfer)
{}
/* The software must wait until TC=1. The TC flag remains cleared during all data
transfers and it is set by hardware at the last frame end of transmission*/
while (USART_GetBitState(USART1, USART_FLAG_TC) == RESET)
{}
/* Enable the USART1 Receive interrupt: this interrupt is generated when the
USART1 receive data register is not empty */
USART_INT_Set(USART1, USART_INT_RBNE, ENABLE);
/* Wait until USART1 receive the RxBuffer */
while(RxCount < NbrOfDataToRead)
{}
if(RxCount == NbrOfDataToRead)
printf("\n\r USART receive successfully!\n\r");
/* Infinite loop */
while (1)
{
}
} |