Hi TI team:
在使用FR2433的串口通讯时,出现串口1无法收发数据,改变端口配置为串口0 时,收发正常。手册中未查到串口A0和A1有差异,程序使用样的配置A1却无法正常收发。
//串口都配置9600bps,目前串口0可以与串口工具进行收发数据,但是串口1接收数据进不到中断里
//串口1发送数据,串口工具也无法接收,用示波器观察单片机端口没有数据。
请TI 帮忙看看,谢谢。
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi TI team:
在使用FR2433的串口通讯时,出现串口1无法收发数据,改变端口配置为串口0 时,收发正常。手册中未查到串口A0和A1有差异,程序使用样的配置A1却无法正常收发。
//串口都配置9600bps,目前串口0可以与串口工具进行收发数据,但是串口1接收数据进不到中断里
//串口1发送数据,串口工具也无法接收,用示波器观察单片机端口没有数据。
请TI 帮忙看看,谢谢。
以上传请查收帮忙看下,谢谢。
void USART0Initialize(void) { P1SEL0 |= BIT4+BIT5; UCA0CTLW0 |= UCSWRST; // Put eUSCI in reset UCA0CTLW0 |= UCSSEL__SMCLK; UCA0BR0 = 0x06; // 1000000/16/9600 UCA0BR1 = 0x00; UCA0MCTLW = UCOS16 | UCBRF_8; UCA0CTLW0 &= ~UCSWRST; // Initialize eUSCI UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt } void USART1Initialize1(void) { P2SEL0 |= BIT5+BIT6; UCA1CTLW0 |= UCSWRST; // Put eUSCI in reset UCA1CTLW0 |= UCSSEL__SMCLK; UCA1BR0 = 0x06; // 1000000/16/9600 UCA1BR1 = 0x00; UCA1MCTLW = UCOS16 | UCBRF_8; UCA1CTLW0 &= ~UCSWRST; // Initialize eUSCI UCA1IE |= UCRXIE; // Enable USCI_A1 RX interrupt } #pragma vector=USCI_A1_VECTOR __interrupt void USCI_A1_ISR(void) { _DINT(); _BIC_SR_IRQ(LPM3_bits); fnReDatausart1_rx(); } #pragma vector=USCI_A0_VECTOR __interrupt void USCI_A0_ISR(void) { UCA0IFG &= ~UCRXIFG; } //���ڶ�����9600bps,Ŀǰ����0�����봮�ڹ��߽����շ����ݣ����Ǵ���1�������ݽ������ж��� //����1�������ݣ����ڹ���Ҳ�����գ���ʾ�����۲쵥Ƭ���˿�û������
请您使用下面的程序,UART1,测试正常
/* --COPYRIGHT--,BSD_EX * Copyright (c) 2014, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ******************************************************************************* * * MSP430 CODE EXAMPLE DISCLAIMER * * MSP430 code examples are self-contained low-level programs that typically * demonstrate a single peripheral function or device feature in a highly * concise manner. For this the code may rely on the device's power-on default * register values and settings such as the clock configuration and care must * be taken when combining code from several examples to avoid potential side * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware * for an API functional library-approach to peripheral configuration. * * --/COPYRIGHT--*/ //****************************************************************************** // MSP430FR243x Demo - eUSCI_A1 UART echo at 9600 baud using BRCLK = 16MHz // // Description: This demo echoes back characters received via a PC serial port. // SMCLK/ DCO is used as a clock source and the device is put in LPM3 // The auto-clock enable feature is used by the eUSCI and SMCLK is turned off // when the UART is idle and turned on when a receive edge is detected. // Note that level shifter hardware is needed to shift between RS232 and MSP // voltage levels. // // The example code shows proper initialization of registers // and interrupts to receive and transmit data. // To test code in LPM3, disconnect the debugger. // // ACLK = REFO = 32768Hz, MCLK = DCODIV = SMCLK = 16MHz. // // MSP430FR2433 // ----------------- // /|\| | // | | | // --|RST | // | | // | | // | P2.6/UCA1TXD|----> PC (echo) // | P2.5/UCA1RXD|<---- PC // | | // // Ling Zhu // Texas Instruments Inc. // Nov 2019 // Built with IAR Embedded Workbench v7.10 & Code Composer Studio v7.3 //****************************************************************************** #include <msp430.h> void Init_GPIO(); int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer // Configure GPIO Init_GPIO(); PM5CTL0 &= ~LOCKLPM5; // Disable the GPIO power-on default high-impedance mode // to activate 1previously configured port settings // Configure one FRAM waitstate as required by the device datasheet for MCLK // operation beyond 8MHz _before_ configuring the clock system. FRCTL0 = FRCTLPW | NWAITS_1; __bis_SR_register(SCG0); // disable FLL CSCTL3 |= SELREF__REFOCLK; // Set REFO as FLL reference source CSCTL0 = 0; // clear DCO and MOD registers CSCTL1 &= ~(DCORSEL_7); // Clear DCO frequency select bits first CSCTL1 |= DCORSEL_5; // Set DCO = 16MHz CSCTL2 = FLLD_0 + 487; // DCOCLKDIV = 16MHz __delay_cycles(3); __bic_SR_register(SCG0); // enable FLL while(CSCTL7 & (FLLUNLOCK0 | FLLUNLOCK1)); // FLL locked CSCTL4 = SELMS__DCOCLKDIV | SELA__REFOCLK; // set default REFO(~32768Hz) as ACLK source, ACLK = 32768Hz // default DCOCLKDIV as MCLK and SMCLK source // Configure UART pins P2SEL0 |= BIT5 | BIT6; // set 2-UART pin as second function // Configure UART UCA1CTLW0 |= UCSWRST; UCA1CTLW0 |= UCSSEL__SMCLK; // Baud Rate calculation // 16000000/(16*9600) = 104.167 // Fractional portion = 0.167 // User's Guide Table 14-4: UCBRSx = 0x11 // UCBRFx = int ( (104.167-104)*16) = 2 UCA1BR0 = 104; // 16000000/16/9600 UCA1BR1 = 0x00; UCA1MCTLW = 0x1100 | UCOS16 | UCBRF_2; UCA1CTLW0 &= ~UCSWRST; // Initialize eUSCI UCA1IE |= UCRXIE; // Enable USCI_A0 RX interrupt __bis_SR_register(LPM3_bits|GIE); // Enter LPM3, interrupts enabled __no_operation(); // For debugger } #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__) #pragma vector=USCI_A1_VECTOR __interrupt void USCI_A1_ISR(void) #elif defined(__GNUC__) void __attribute__ ((interrupt(USCI_A1_VECTOR))) USCI_A1_ISR (void) #else #error Compiler not supported! #endif { switch(__even_in_range(UCA1IV,USCI_UART_UCTXCPTIFG)) { case USCI_NONE: break; case USCI_UART_UCRXIFG: while(!(UCA1IFG&UCTXIFG)); UCA1TXBUF = UCA1RXBUF; __no_operation(); break; case USCI_UART_UCTXIFG: break; case USCI_UART_UCSTTIFG: break; case USCI_UART_UCTXCPTIFG: break; default: break; } } void Init_GPIO() { P1DIR = 0xFF; P2DIR = 0xFF; P3DIR = 0xFF; P1REN = 0xFF; P2REN = 0xFF; P3REN = 0xFF; P1OUT = 0x00; P2OUT = 0x00; P3OUT = 0x00; }