初级会员
- 积分
- 119
- 金钱
- 119
- 注册时间
- 2015-7-2
- 在线时间
- 5 小时
|
楼主 |
发表于 2015-7-25 12:10:45
|
显示全部楼层
回复【2楼】joe_knight:
---------------------------------
int main(void)
{
u8 len ;
/* Infinite loop */
/*设置内部时钟16M为主时钟*/
CLK_HSICmd(ENABLE);
CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);
/*!<Set High speed internal clock */
ADC1_DeInit();
ADC1_Cmd(DISABLE);
ADC1_SchmittTriggerConfig(ADC1_SCHMITTTRIG_CHANNEL6, ENABLE);
ADC1_SchmittTriggerConfig(ADC1_SCHMITTTRIG_CHANNEL5, ENABLE);
GPIO_Init(GPIOD, GPIO_PIN_6, GPIO_MODE_IN_FL_NO_IT);
GPIO_Init(GPIOD, GPIO_PIN_5, GPIO_MODE_OUT_PP_HIGH_FAST);
Uart_Init();
CLK_PeripheralClockConfig(CLK_PERIPHERAL_UART1, ENABLE);
__enable_interrupt();
printf("\r\n硬件平台为:%s\r\n","iCreate STM8 开发板");
UART1_SendString("Serial Communication ---STM8 Development Board of FengChi Electron ",\
sizeof("Serial Communication ---STM8 Development Board of FengChi Electron"));
Delay(0xffff);
UART1_SendByte('\n');
Delay(0xffff);
while (1)
{
printf("\r\n硬件平台为:%s\r\n","iCreate STM8 开发板");
if(UART_RX_NUM&0x80)
{
len=UART_RX_NUM&0x3f;/*得到此次接收到的数据长度*/
UART1_SendString("You sent the messages is:",sizeof("You sent the messages is"));
UART1_SendString(RxBuffer,len);
UART1_SendByte('\n');
UART_RX_NUM=0;
}
}
}
串口就是这样配置的,不知道哪里有问题,不能发送也不能接受,硬件连接没问题啊,> |
|