int main(void) { STM_EVAL_LEDInit(LED3); STM_EVAL_LEDInit(LED4); STM_EVAL_LEDInit(LED5); STM_EVAL_LEDOn(LED4); //configure clock for USART RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE); //configure clock for GPIO RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE); //configure AF GPIO_PinAFConfig(GPIOD,GPIO_PinSource8,GPIO_AF_USART3); GPIO_PinAFConfig(GPIOD,GPIO_PinSource9,GPIO_AF_USART3); //configure ports, &GPIO_InitStructure); GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; GPIO_Init(GPIOD, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; GPIO_Init(GPIOD, &GPIO_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_Rx | USART_Mode_Tx; USART_Init(USART3, &USART_InitStructure); /* Enable USART */ USART_Cmd(USART3, ENABLE); for(i=0; i<1000; i++){ USART_SendData(USART3, 'x'); while(USART_GetFlagStatus(USART3, USART_FLAG_TXE) == RESET); } // do // { // while(USART_GetFlagStatus(USART3, USART_FLAG_RXNE) == RESET); // i++; ///* } while((*/c = USART_ReceiveData(USART3)/*)!= 'x')*/; if(c == 'x') STM_EVAL_LEDOn(LED3); else STM_EVAL_LEDOff(LED4); while(1); }