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 everyone,
I was using MSP430G2553 then I switched to FR5994. For testing UART comminication I was using two codes, one of them is utilizing polling and the other one is utilizing interruppts for user buttons. I read related parts of the family user's guide for MSP430fr5994 and I performed necessary changes on those codes for testing UART in FR994. Codes are working properly but I cannot read any data on the CCS terminal. I spend too much time to resolve the issue but i cannot come up with a solution. Both two codes are added below
I would be glad if you could help. Thank you...
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//UART test 1 - Polling #include <msp430.h> #define RXD BIT1 #define TXD BIT0 #define BUTTON BIT5 void UART_TX(char * tx_data); // Function Prototype for TX void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop Watch dog timer // Disable the GPIO power-on default high-impedance mode to activate previously configured port settings PM5CTL0 &= ~LOCKLPM5; // Clock setup CSCTL0_H = CSKEY >> 8; // Unlock CS registers CSCTL1 = DCOFSEL_3 | DCORSEL; //Set DCO to 8MHz CSCTL2 = SELA__VLOCLK | SELS__DCOCLK | SELM__DCOCLK; // Set ACLK = VLOCLK; MCLK = SMCLK = DCO CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1; // Set all dividers to 1 // Lock CS registers CSCTL0_H = 0; P5DIR &=~BUTTON; // Ensure button is input P1OUT &= ~BIT0; // Clear P1.0 output latch P1DIR |= BIT0; // For LED P5OUT |= BUTTON; // Enables pullup resistor on button P5REN |= BUTTON; P6SEL1 &= ~(BIT0 | BIT1); P6SEL0 |= (BIT0 | BIT1); // USCI_A3 UART operation UCA3CTLW0 = UCSWRST; // Put eUSCI in reset UCA3CTLW0 |= UCSSEL__SMCLK; // CLK = SMCLK // Baud Rate calculation // 8000000/(16*9600) = 52.083 // Fractional portion = 0.083 // User's Guide Table 21-4: UCBRSx = 0x04 // UCBRFx = int ( (52.083-52)*16) = 1 UCA3BRW = 52; // 8000000/16/9600 UCA3MCTLW |= UCOS16 | UCBRF_1 | 0x0400; // UCA3CTLW0 &= ~UCSWRST; // Initialize eUSCI while(1) // polling { if(!((P5IN & BUTTON)==BUTTON)) // Was button pressed? { P1OUT ^= BIT0; // to ensure code is working - red led will be toggled as button is pressed UART_TX("Hello World! \r\n"); // If yes, Transmit message __delay_cycles(2000000); //not to Debounce button so signal is not sent multiple times } } } void UART_TX(char * tx_data) // Define a function which accepts a character pointer to an array { unsigned int i=0; while(tx_data[i]) // Increment through array, look for null pointer (0) at end of string { while ((UCA3STATW & UCBUSY)); // Wait if line TX/RX module is busy with data UCA3TXBUF = tx_data[i]; // Send out element i of tx_data array on UART bus i++; // Increment variable for array address } }
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//UART test 2 - interrupts #include<msp430.h> //prototypes void UARTInit(void); void TXData(unsigned char c); void main(void){ WDTCTL = WDTPW + WDTHOLD;// watchdog timer kapali // Clock setup CSCTL0_H = CSKEY >> 8; // Unlock CS registers //CSCTL1 = DCOFSEL_0; // Set DCO to 1MHz CSCTL1 = DCOFSEL_3 | DCORSEL; //Set DCO to 8MHz CSCTL2 = SELA__VLOCLK | SELS__DCOCLK | SELM__DCOCLK; // Set ACLK = VLOCLK; MCLK = SMCLK = DCO CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1; // Set all dividers to 1 // Lock CS registers CSCTL0_H = 0; // Disable the GPIO power-on default high-impedance mode to activate previously configured port settings PM5CTL0 &= ~LOCKLPM5; P1OUT &= ~BIT0; // Clear P1.0 output latch P1DIR |= BIT0; // For LED P5DIR &= ~BIT5; //P5.5 input P5OUT |= BIT5; P5REN |= BIT5; // Enables pullup resistor on button P5IE |= BIT5; // interrupt enabled P5IES |= BIT5; // Hi/lo edge P5IFG &= ~BIT5; // IFG cleared UARTInit(); __bis_SR_register(GIE); } void UARTInit(void){ P6SEL1 &= ~(BIT0 | BIT1); P6SEL0 |= (BIT0 | BIT1); // USCI_A3 UART operation UCA3CTLW0 = UCSWRST; // Put eUSCI in reset UCA3CTLW0 |= UCSSEL__SMCLK; // CLK = SMCLK // Baud Rate calculation // 8000000/(16*9600) = 52.083 // Fractional portion = 0.083 // User's Guide Table 21-4: UCBRSx = 0x04 // UCBRFx = int ( (52.083-52)*16) = 1 UCA3BRW = 52; // 8000000/16/9600 UCA3MCTLW |= UCOS16 | UCBRF_1 | 0x0400; UCA3CTLW0 &= ~UCSWRST; // Initialize eUSCI UCA3IE |= UCRXIE; } void TXData(unsigned char c){ while(!(UCA3IFG & UCTXIFG)); UCA3TXBUF = c; } // Port 1 interrupt service routine/**/ #pragma vector=PORT5_VECTOR __interrupt void Port_5(void) { P1OUT ^= BIT0; TXData('M'); __delay_cycles(400000); prevent multiple send P5IFG &= ~BIT5; }
*********************************************************************************************************************************************************************************************************
**Attention** This is a public forum