那位帮我看下,我的串口收到的数据不对,问题出在哪啊?
附代码:
uchar tab[4]={0x09,0x30,0x31,0x30};
void UART_Init(void)
{
LINUART_CR2 = 0x00; //disable Tx & Rx
/* LINUART configured as follow:
- BaudRate = 115200 baud
- Word Length = 8 Bits
- One Stop Bit
- No parity
- Receive and transmit enabled
- LINUART Clock disabled
*/
/* Configure UART1 */
LINUART_CR1 = 0x00;
LINUART_CR3 = 0x00;
LINUART_BRR2 = 0x00;
LINUART_BRR1 = 0x06;
//LINUART_BRR2 = 0x0B;
//LINUART_BRR1 = 0x08;
LINUART_CR2 |= 0x0C;
}
void send(void) //发送的字符型
{
unsigned int i;
for(i=0;i<4;i++)
{ while (!(LINUART_SR & 0x40));
LINUART_DR = tab[i];
}
}
void main()
{
unsigned int i;
unsigned char counter = 0;
CLK_Init();
UART_Init();
GPIO_Init();
send();
while(1);
}
这是串口收到的数据 C0 73 6D 03 完全不对,我要是发字符 就出现乱码。 |