qiancuit2012 发表于 2014-9-30 17:05:24

stm8s207串口收发问题

如题,求代码
一电脑串口助手发送字符串,stm8s接收到后,并发送出去;

michrome 发表于 2014-9-30 17:44:02

void Uart3Init()//115200
{
UART3_CR2 = 0x00;    //disable Tx & Rx
/* UART1 configured as follow:16M内部高速振荡器
- BaudRate = 9600 baud
- Word Length = 8 Bits
- Receive and transmit enabled
- UART1 Clock disabled
Configure UART1 */
UART3_CR1= 0x00;//No parity
UART3_CR3= 0x00;//One Stop Bit
UART3_BRR2 = 0x05;
UART3_BRR1 = 0x04;
UART3_CR2= 0x2C;//允许发送/接收中断
}
void Uart1Init()
{
UART1_CR2 = 0x00;    //disable Tx & Rx
/* UART1 configured as follow:16M内部高速振荡器
- BaudRate = 9600 baud
- Word Length = 8 Bits
- Receive and transmit enabled
- UART1 Clock disabled
Configure UART1 */
UART1_CR1= 0x00;//No parity
UART1_CR3= 0x00;//One Stop Bit
UART1_BRR2 = 0x01;
UART1_BRR1 = 0x34;
UART1_CR2= 0x2C;//允许发送/接收中断
}
页: [1]
查看完整版本: stm8s207串口收发问题