共2条
1/1 1 跳转至页
FE427 【讨论】谁能告诉我一下FE427的串口通信初始化参数吗?
问
【讨论】谁能告诉我一下FE427的串口通信初始化参数吗?我用的是研讨会上的实验板。现在想做串口通讯,可是参考书上的关键字是按F149来设置的,我找到光盘上没有FE427系列的,只有F449之类的。恳请DX们帮助!!
答 1:
void Init(void)
{
UCTL1 &=~SWRST;
UCTL1=0x10;
UBR01=0x03;
UBR11=0x00;
UMCTL1=0x4A;
UTCTL1=0x10;
ME2 |=0x20;
P3SEL=0x40;
P3DIR=0x40;
书上是这样的。 答 2: void InitUART(unsigned long baud)
{
//UART
// Configure USART in UART mode, 8-bit, 1-stop, no parity.
// Hold logic in reset state while configuring other registers
UCTL0 = (0*PENA) // 7 Parity Enable 0=Disabled
|(0*PEV) // 6 Parity Select 0= Odd
|(0*SPB) // 5 Stop Bit Select 0= 1 Stop bit
|(1*CHAR) // 4 Character Length 1= 8-bit data
|(0*LISTEN) // 3 Loopback control 0= Loopback disabled
|(0*SYNC) // 2 Synchronous Mode 0= UART mode
|(0*MM) // 1 Multiprocessor Mode 0= Idle-line multiproc control
|(1*SWRST); // 0 Software Reset 1= Logic Held in Reset State ...
// while configuring other registers
switch(baud)
{
case 9600:
UTCTL0 = SSEL0; // UCLK = ACLK
UBR00 = 0x03; // 32k/9600
UBR10 = 0x00; //
UMCTL0 = 0x4a; //
break;
case 19200:
UTCTL0 = SSEL1; // UCLK = SMCLK
UBR00 = 0xDA; // 4MHz/19200
UBR10 = 0x00; //
UMCTL0 = 0x55; //
break;
case 57600:
UTCTL0 = SSEL1; // UCLK = SMCLK
UBR00 = 0x48; // 4Mhz/57600
UBR10 = 0x00; //
UMCTL0 = 0x7B; //
break;
case 115200:
UTCTL0 = SSEL1; // UCLK = SMCLK
UBR00 = 0x24; // 4Mhz/115.2k
UBR10 = 0x00; //
UMCTL0 = 0x29; //
break;
default:
break;
}
U0ME |= UTXE0+URXE0 ; // Enabled USART0 TXD/RXD
P2SEL |= (BIT4 + BIT5); // P2.4,5 = USART0 TXD/RXD
P2DIR |= BIT4; // P2.4 output direction
U0IFG &= ~URXIFG0; // Clear USART0 RX interrupt flag
UCTL0 &= ~(SWRST); // 8-bit character - clr SWRST bit
// U0IE |= URXIE0+UTXIE0; // Enable USART0 RX + TX interrupt
U0IE |= URXIE0; // Enable USART0 RX interrupt
} 答 3: 太谢谢啦,要是我产品成功调试出来,我会意思意思的。:)
{
UCTL1 &=~SWRST;
UCTL1=0x10;
UBR01=0x03;
UBR11=0x00;
UMCTL1=0x4A;
UTCTL1=0x10;
ME2 |=0x20;
P3SEL=0x40;
P3DIR=0x40;
书上是这样的。 答 2: void InitUART(unsigned long baud)
{
//UART
// Configure USART in UART mode, 8-bit, 1-stop, no parity.
// Hold logic in reset state while configuring other registers
UCTL0 = (0*PENA) // 7 Parity Enable 0=Disabled
|(0*PEV) // 6 Parity Select 0= Odd
|(0*SPB) // 5 Stop Bit Select 0= 1 Stop bit
|(1*CHAR) // 4 Character Length 1= 8-bit data
|(0*LISTEN) // 3 Loopback control 0= Loopback disabled
|(0*SYNC) // 2 Synchronous Mode 0= UART mode
|(0*MM) // 1 Multiprocessor Mode 0= Idle-line multiproc control
|(1*SWRST); // 0 Software Reset 1= Logic Held in Reset State ...
// while configuring other registers
switch(baud)
{
case 9600:
UTCTL0 = SSEL0; // UCLK = ACLK
UBR00 = 0x03; // 32k/9600
UBR10 = 0x00; //
UMCTL0 = 0x4a; //
break;
case 19200:
UTCTL0 = SSEL1; // UCLK = SMCLK
UBR00 = 0xDA; // 4MHz/19200
UBR10 = 0x00; //
UMCTL0 = 0x55; //
break;
case 57600:
UTCTL0 = SSEL1; // UCLK = SMCLK
UBR00 = 0x48; // 4Mhz/57600
UBR10 = 0x00; //
UMCTL0 = 0x7B; //
break;
case 115200:
UTCTL0 = SSEL1; // UCLK = SMCLK
UBR00 = 0x24; // 4Mhz/115.2k
UBR10 = 0x00; //
UMCTL0 = 0x29; //
break;
default:
break;
}
U0ME |= UTXE0+URXE0 ; // Enabled USART0 TXD/RXD
P2SEL |= (BIT4 + BIT5); // P2.4,5 = USART0 TXD/RXD
P2DIR |= BIT4; // P2.4 output direction
U0IFG &= ~URXIFG0; // Clear USART0 RX interrupt flag
UCTL0 &= ~(SWRST); // 8-bit character - clr SWRST bit
// U0IE |= URXIE0+UTXIE0; // Enable USART0 RX + TX interrupt
U0IE |= URXIE0; // Enable USART0 RX interrupt
} 答 3: 太谢谢啦,要是我产品成功调试出来,我会意思意思的。:)
共2条
1/1 1 跳转至页
回复
有奖活动 | |
---|---|
【有奖活动——B站互动赢积分】活动开启啦! | |
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |