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.

MSP430F5438 USCI_A0, 9600 UART, SMCLK, LPM0, Echo with over-sampling Example

Other Parts Discussed in Thread: MSP430F5438

Hi,

I tried to run MSP430x54x_uscia0_uart_04.c from Slac227 from TI website
At the Readme file this source is described as USCI_A0, 9600 UART, SMCLK, LPM0, Echo with over-sampling.
I made some changes, like turning on a LED and the LCD Display, however if I use the funtion halLcdClearScreen() and download the code in MSP430F5438, the debugger starts and it never comes the green highlighting on the code. It is like it^s running but you can't debug. By simple removing halLcdClearScreen(), it works again. Does anyone know what is wrong? The same happens with halLcdSetContrast(70) and halLcdPrintXY("test", 0,0,0);

 

#include "msp430x54x.h"
#include "MSP-EXP430F5438 HAL\hal_MSP-EXP430F5438.h"

void main(void)
{

    //Initialize clock and peripherals
  halBoardInit(); 
 
  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
  P3SEL = 0x30;                             // P3.4,5 = USCI_A0 TXD/RXD
  UCA0CTL1 |= UCSWRST;                      // **Put state machine in reset**
  UCA0CTL1 |= UCSSEL_2;                     // SMCLK
  UCA0BR0 = 6;                              // 1MHz 9600 (see User's Guide)
  UCA0BR1 = 0;                              // 1MHz 9600
  UCA0MCTL = UCBRS_0 + UCBRF_13 + UCOS16;   // Modln UCBRSx=0, UCBRFx=0,
                                            // over sampling
  UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
  UCA0IE |= UCRXIE;                         // Enable USCI_A0 RX interrupt
 
  LED_PORT_OUT ^= LED_1;
  halLcdInit();
  halLcdBackLightInit();
  halLcdSetBackLight(200);
  //halLcdSetContrast(70);
  //halLcdClearScreen();

  __bis_SR_register(LPM0_bits + GIE);       // Enter LPM0, interrupts enabled
  __no_operation();                         // For debugger
 
  halLcdClearScreen();
    //halLcdPrintXY("test", 0,0,0);
}


// Echo back RXed character, confirm TX buffer is ready first
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
{
  switch(__even_in_range(UCA0IV,4))
  {
  case 0:break;                             // Vector 0 - no interrupt
  case 2:                                   // Vector 2 - RXIFG
    LED_PORT_OUT ^= LED_2;
    while (!(UCA0IFG&UCTXIFG));             // USCI_A0 TX buffer ready?
    UCA0TXBUF = UCA0RXBUF;                  // TX -> RXed character
    break;
  case 4:break;                             // Vector 4 - TXIFG
  default: break;
  }
}

  • It sounds like your WDT is restarting the part before you ever get to turning it off.  Move this line above your initialization call:

    WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT

    Whatever variables are declared/initialized in that init function may have been optimized out by the compiler when you did not use the halLcdClearScreen, halLcdSetContrast, and halLcdPrintXY functions.  However, when you use those functions, the compiler no longer skip over unused variables therefore probably making your init function longer than your default watchdog timer interval.

  • I tried like this and still no use:

    #include "msp430x54x.h"
    #include "MSP-EXP430F5438 HAL\hal_MSP-EXP430F5438.h"

    void main(void)
    {
       WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
      
        //Initialize clock and peripherals
      halBoardInit(); 
     
      P3SEL = 0x30;                             // P3.4,5 = USCI_A0 TXD/RXD
      UCA0CTL1 |= UCSWRST;                      // **Put state machine in reset**
      UCA0CTL1 |= UCSSEL_2;                     // SMCLK
      UCA0BR0 = 6;                              // 1MHz 9600 (see User's Guide)
      UCA0BR1 = 0;                              // 1MHz 9600
      UCA0MCTL = UCBRS_0 + UCBRF_13 + UCOS16;   // Modln UCBRSx=0, UCBRFx=0,
                                                // over sampling
      UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
      UCA0IE |= UCRXIE;                         // Enable USCI_A0 RX interrupt
     
      LED_PORT_OUT ^= LED_1;
      halLcdInit();
      halLcdBackLightInit();
      halLcdSetBackLight(200);
      halLcdSetContrast(70);
      halLcdClearScreen();

      __bis_SR_register(LPM0_bits + GIE);       // Enter LPM0, interrupts enabled
      __no_operation();                         // For debugger

  • I have noticed that the dubugger will sometimes begin in an interrupt routine.  You might try commenting out some of the lines in the interrupt routine to see if that has an effect.

**Attention** This is a public forum