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.

MSP430 code works on TI/GNU-C but not on IAR

Other Parts Discussed in Thread: MSP430F6736

I added a short code at the end. The code is based on TI's example code for MSP430F6x series to output data on an UART port. I use MSP430F6736.

That code works fine on Code Composer Studio v6 with TI's or GNUC compilers. What I mean fine is that the MCU output the correct data when it is run. I can verify that the data is output by using an oscilloscope and UART is connected to a Linux device that receives data correctly.

I use IAR Workbench for MSP430 IDE v6.10.7common components v7.0.5.3137. When I run the below code on IAR, it executes the code but does not output any signal at the UART port, so that I don't see any data on the Linux end device does either. I use the same settings on both IAR or CCS usage. Could you please tell me why the code does not work on the IAR or if I need some special definition or library for code to work on IAR?

I am using one of TI's EVM based on MSP430F6736. I am connected it on JTAG connector via one of TI's debugger MSP-FET430UIF.

Here is the build output

Building configuration: j - Debug 
Updating build tree... 

4  file(s) deleted. 
Updating build tree... 
main.c  
Warning[Pe111]: statement is unreachable C:\Users\user\Desktop\main.c 36
Linking 

Total number of errors: 0 
Total number of warnings: 1


Here is the code

#include <msp430.h>

void mUART_init(void){
      WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT

     // Setup P1.2 UCA0RXD, P1.3 UCA0TXD
          P1SEL |= BIT2 | BIT3;                   // Set P1.2, P1.3 to non-IO
          P1DIR |= BIT2 | BIT3;                   // Enable UCA0RXD, UCA0TXD
        UCA0CTLW0 |= UCSWRST;                   // **Put state machine in reset**
      UCA0CTLW0 |= UCSSEL_2;                  // SMCLK
      UCA0BRW_L = 6;                          // 1MHz 9600 (see User's Guide)
          UCA0BRW_H = 0;                          // 1MHz 96000
     UCA0MCTLW = UCBRF_13 | UCOS16;          // Modln UCBRSx=0, UCBRFx=0x13,
                                            // over sampling
      UCA0CTLW0 &= ~UCSWRST;                  // **Initialize USCI state machine**
}

void mUART_send(uint32_t send){
    uint8_t MYtx[4];
      MYtx[0] = send;
      MYtx[1] = (send >>8);
      MYtx[2] = (send >>16);
      MYtx[3] = (send >>24);

     int i;
    for(i=0; i<4; i++){
         while (!(UCA0IFG&UCTXIFG));             // USCI_A0 TX buffer ready?
         UCA0TXBUF = MYtx[i];                  // TX -> RXed character
     }
}

int main(void){
    mUART_init();
        while(1)
          mUART_send(0xFEAB);
    return 0;
}

Project > options: MSP430F6736 is selected, code model is large, data model is small, no optimization is selected. Normal DLIB is selected

 
  • A couple of questions....

    1. Have you checked the linker script in IAR to make sure it is correct for your part?

    2. Have you tried stepping through the code with the debugger?

  • Thank you Brian for the reply.

    I am new to IAR, am I checking it correctly? Project> Options > Linker > Config >  "$TOOLKIT_DIR$\config\linker\lnk430F6736.xcl"  is selected.

    I stepped into the function, it gets stuck on  "while (!(UCA0IFG&UCTXIFG)); ". I step the code on CCS, it works fine there. 

    I see that the debug interface was simulation, I changed it to FET debugger, now it works fine. thank you for the help

**Attention** This is a public forum