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.

problems with UART to send data to PC with MSP432 microcontroller

Other Parts Discussed in Thread: ENERGIA

Hello I have some problems with a UART comunication to pc, I use CCS to program my code and to debug the results I use Terminal. So my code works fine and do everything well, the biggest problem is the features dont appear well in Terminal window. Can anyone help me?I  Send my code and image to apreciate 

#include "msp.h"

int main(void){
	UART_TxConfig();
}

void UART_TxConfig(void){
	/*CLOCK SYSTEM SUPORT (CS)*/
	CS->KEY = 0x695A;/*UNLOCK ALL 16 LSB CS REGISTERS*/
	CS->CTL0 = 0;/*RESET PARAMETERS*/
	CS->CTL0 = CS_CTL0_DCORSEL_5;/**/
	/*CLOCK SYSTEM*/
	/*SELA_2		ACLK   = REFOCLK*/
	/*SELS_3		SMCLK  = DCOCLK*/
	/*SELM_3		MCLK   = DCOCLK*/
	CS->CTL1 = CS_CTL1_SELA_2 | CS_CTL1_SELS_3 | CS_CTL1_SELM_3;
	/*LOCK ACESSES TO REGISTERS*/
	CS->KEY = 0;/*UNLOCK ALL 16 LSB CS REGISTERS*/

	/*UART PIN CONFIGURATION*/
	P1-> SEL0 |= BIT2 | BIT3; /*SET 2 UART PIN's*/
	/*ACTIVE INTERRUPTION's*/
	__enable_interrupt();
	/*ACTIVE eUSCIA0 INTERRUPT IN NVIC MODULE*/
	NVIC->ISER[0] = 1 << ((EUSCIA0_IRQn) & 31);
	/*CONFIGURE UART*/
	UCA0CTLW0 |= UCSWRST;
	UCA0CTLW0 |= UCSSEL__SMCLK;/*SELECT SMCLK CLOCK SOURCE*/
	/*BAUD RATE CALCULATION
	 * 12MHz/(16*9600) =78.125
	 *FRACTIONAL PORTION = 0.125
	 *FRACTIONAL
	 */
	UCA0BR0 = 26;/*48000000/16/115200*/
	UCA0BR1 = 0x00;
	UCA0MCTLW = 0x1000 | UCOS16 | 0x0020;
	/*CONTROL WORD REGISTER*/
	UCA0CTLW0 &= ~UCSWRST;  /*SOFTWARE RESET DISABLE*/
	UCA0IE |=UCRXIE;

	while(1){
	UCA0TXBUF = 'A';
	UCA0TXBUF = 'B';
	UCA0TXBUF = 'C';
	UCA0TXBUF = 'D';
	UCA0TXBUF = 0x61;
	}
}

/*UART INTERRUPT SERVICE ROUTINE*/
void EUSCIA0_IRQHandler (void){
	if (UCA0IFG & UCRXIFG){
		while(!(UCA0IFG&UCTXIFG));
	}


}

  • Hello Armando,

    I am going to try reproducing this error, but so far I do not see similar results.  Can you double check that the code you provide is the same as what is producing this error?  I do not get any data flow into the terminal window.  I am using 115200 baud rate with the serial terminal set up as below:

  • Additionally,

    It appears you are using DCO frequency set to 48MHz but you do not change the flash wait states or vcore.  Does this not brick your device when you try this?  It bricks mine every time (I end up having to do factory reset to program it again after this.)

    Another thing I notice is we do not agree with the correct value of UCA0MCTLW.  Where do you get your values for this?  I would have agreed setting UC0S16.  But then I would have used Table 22-4. UCBRSx Settings for Fractional Portion of N = fBRCLK/Baud Rate in the TRM where you used 0x1000 and then this equation

    UCBRFx = INT([(N / 16) – INT(N / 16)] × 16)

    to determine the value where you came up with 0x20.

  • John P. Morrison,
    Thank you for your response, i' am not very familiar, with this uC, and to tell you the truth sincerely, I will follow all your sugestions and considerations. Given this situation what you sugest, can you give me some example, or point me the right way forward to do this alterations, can you help me?
    Thanks in advance.
    So:
  • Just download the 432 driverlib, run the UART echo example and go from there. I can tell you that that works fine on the MSP432 Launchpad.
  • Sure!

    I can definitely refer you to some examples.  The register level example, here, shows how to setup the VCORE, flash wait states, configure DCO TO 48MHz, and set MCLK to use DCO; all at the register level.

    You could also use a slower clock speed if you do not require 48MHz operation, then you wouldn't need to change defaults for VCORE or Flash Wait States.

    Keith makes a fair point.  Using the driverlib example, here, is a great resource and could be your fastest easiest implementation.  DriverLib has extrememly user friendly APIs.

  • You certainly have a different perspective on API's than I do. 8^) I wouldn't say "extremely" user friendly.

    If I would rate them:

    Energia: Friendly API

    DriverLib: English API that is relatively easy to use.

    Register programming: Arcane and difficult API.

  • My friends,
    I have already made the changes that John P. Morrison suggested. Of course it is not to work at such a high frequency.
    It's just for testing, now I'll make some adjustments and maybe it will work with a typical crystal frequency such as 32768

**Attention** This is a public forum