📄 uart.c
字号:
#include "main.h"
void uart_init(void)
{
/* UART1 is used to configure the transceiver ... */
U0CTL|=SWRST;
// 8 bit char...
U0CTL=SWRST|0x10;
// U1TCTL=0011 0001
U0TCTL=0x31; /* no wakeup, use SMCLK for baud clock */
U0RCTL=0; /* no wakeup, no error interrupt */
// baud rate
/* http://mspgcc.sourceforge.net/baudrate.html ;-) */
U0BR0=0x56;
U0BR1=0x00;
U0MCTL=0x94;
/* Port configuration ...*/
P3SEL |= 0x30; // P3.4,5 = USART0 TXD/RXD
// enable module
ME1|=UTXE0|URXE0;
//clear flags ....
IFG1&=~(UTXIFG0|URXIFG0);
U0CTL&=~SWRST;
/* At the moment I don't want any kind of interrupt here ....*/
//IE2|=UTXIE1|URXIE1;
}
int putchar(int ch)
{
//char dummy;
while(!(IFG1 & UTXIFG0));
TXBUF0 = ch;
return ch;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -