|
上位机-->rxbuf0-->txbuf1-->传感器 数据:传感器-->rxb...
[复制链接]
想通过msp430f149将上位机的命令从uart0上发出去,再将数据通过149从uart1返回上位机,
即命令:上位机-->rxbuf0-->txbuf1-->传感器
数据:传感器-->rxbuf1-->txbuf0-->上位机
示波器观察txbuf1已经没有信号!
新手求指教,勿喷,谢谢! | #include
//char *Re;
//unsigned int i=0;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P3SEL |= 0xf0; // P3.4,5,6,7 = USART0,1 TXD/RXD
P3DIR |=0X50; //P3.4,6=TXD
ME1 |= UTXE0 + URXE0; // Enable USART0 TXD/RXD
ME2 |= UTXE1 + URXE1; // Enable USART1 TXD/RXD
UCTL0 |= CHAR; // 8-bit character
UCTL1 |= CHAR;
// UCTL0 |= PENA + PEV;
// UCTL1 |= PENA + PEV;
UTCTL0 |= SSEL1; // UCLK = ACLK
UTCTL1 |= SSEL1;
UBR00 = 0x06; // 32k/4800 - 13.65
UBR10 = 0x00;
UBR01 = 0x06; // 32k/4800 - 3.41
UBR11 = 0x00; //
UMCTL0 = 0x6b; // Modulation
UMCTL1 = 0x6b;
UCTL0 &= ~SWRST;
UCTL1 &= ~SWRST; // Initialize USART state machine
IE1 |= URXIE0; // Enable USART0 RX interrupt
IE2 |= URXIE1; // Mainloop
_EINT();
for (;;)
{
_BIS_SR(LPM3_bits + GIE); // Enter LPM3 w/interrupt
}
}
#pragma vector=UART0RX_VECTOR
__interrupt void usart0_rx (void)
{
_BIC_SR_IRQ(LPM3_bits); // Clear LPM3 bits from 0(SR)
TXBUF0 = RXBUF0;
}
#pragma vector=UART1RX_VECTOR
__interrupt void usart1_rx (void)
{
_BIC_SR_IRQ(LPM3_bits); // Clear LPM3 bits from 0(SR)
TXBUF0 = RXBUF1;
}
|
|