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.

MSP430F1612, RS232 communication

Other Parts Discussed in Thread: MSP430F1612

Hello,

I have MSP430F1612 with RS232 transceiver connected to USART0. For testing and learning purposes, I use Hyper terminal to communicate with PC in idle-line mode. When transmitting to PC, everything is OK.

For receiving characters from PC using also idle-line mode with the same parameters used to transmit to PC, I do not understand well what should I check for receiving the entire character on MSP430F1612 side. When checking with oscilloscope the pulses sent by PC, everything is OK, clean signals. Can anybody help me?

Regards,

Nicolae

  • Did you check source code examples? Which part you did not understand?

  • Nicolae Miron said:
    Can anybody help me?

    To help you, you need to show us the part of the code which; initialize, sent/receive and the ISR for the USART.

  • Nicolae Miron said:
    For receiving characters from PC using also idle-line mode

    Idle-line mode is for multiprocessor usage. Receiving in idle-line mode means that there must be some dead-time (>10 bits of idle time) before the transmission, then an address follows that has to match the 'own address' of the USART, or else the USART will ignore the transmission.

    If you just want to receive what's on the line, don't use idle line multiprocessor mode.

  • Thanks everybody for trying to help me. For better understanding, you have the code below:

    #include <io430x16x.h>
    #include <intrinsics.h>

    void main(void)
    {
      //Stop WDT
      WDTCTL = WDTPW + WDTHOLD + WDTTMSEL; 
     //dis GIE
      __bic_SR_register(GIE);
     
      // 9600 baud; 
      unsigned char u0br_1 = 0x00;
      unsigned char u0br_0 = 0x6D;
      unsigned char u0_mctl = 0x03;
      //store RsDat in  RAM starting at 0x2480
      unsigned short rx_ram_adr = 0x2480;
     

      // ========= for TxD only =========
      // "$"
     // unsigned char u0_txdat_1 = 0x24;
      // "1"
     // unsigned char u0_txdat_2 = 0x31;
      // "2"
     // unsigned char u0_txdat_3 = 0x32;
      // "3"
     // unsigned char u0_txdat_4 = 0x33;
      // "space"
     // unsigned char u0_txdat_idle = 0xFF;
      // array
     // unsigned char chArray[5];
     // chArray[0] = u0_txdat_1;
     // chArray[1] = u0_txdat_2;
     // chArray[2] = u0_txdat_3;
     // chArray[3] = u0_txdat_4;
     // chArray[4] = u0_txdat_idle;
       
     // int szchArray = sizeof(chArray);
     // int jarray = 1;
    // ======== END of TxD initialization ============ 
     
     // Timer param.
     // counting index
     // unsigned short ix;
     // max index value
     // unsigned short maxix = 650;    
     
      //============ Set ACLK, XT2CLK ==========================
      //SELM1=1; SELM0=0 selects also DCOCLK: BUG? Check this.
      //Impossible to select MCLK from XT2CLK
      //XT2 ON
      BCSCTL1 &= ~XT2OFF;
      //LFXT1 with 32768Hz crystal, OK
      BCSCTL1 &= ~XTS;
      // ACLK /1
      BCSCTL1 &= ~DIVA1;
      BCSCTL1 &= ~DIVA1; //ACLK /1
      // XT2CLK sel
      BCSCTL2 |= SELM1;
      BCSCTL2 &= ~SELM0; //XT2CLK sel;
      // SMCLK from MCLK
      BCSCTL2 |= SELS; // SMCLK from MCLK
      // SMCLK = MCLK 1/4; USART req. 1.0486MHz~=0.95us
      BCSCTL2 |= DIVS1;
      BCSCTL2 &= ~DIVS0;
      // Internal Resistor
      BCSCTL2 &= ~DCOR;
      //================= End CLK INIT =========================
     
       //========== Init MSP430F1612 USART0 / RS232 use UTXD0, URXD0 ======================
      //Port P3.4, P3.5
     
        // P3.4 TxD
        P3SEL |= P3SEL_4;
        // P3.4 OUT
        P3DIR |= P3DIR_4;
        // P3.4 TxD
        P3OUT |= P3OUT_4;
      
        // P3.5. RxD
        P3SEL |= P3SEL_5;
        // P3.5 IN
        P3DIR &= ~P3DIR_5;
        // read RxD
        P3IN |= __READ P3IN_5;
       
         // P3.6. Error_LED
        P3SEL |= P3SEL_6;
        // P3.6 OUT
        P3DIR |= P3DIR_6;
        // OUT LED_off
        P3OUT &= ~P3OUT_6;   
     
        // P3.7. Check Rx
        P3SEL |= P3SEL_7;
        // P3.7 OUT
        P3DIR |= P3DIR_7;
        // OUT Low
        P3OUT &= ~P3OUT_7;     
       
         // P5.4 funct
        P5SEL &= ~P5SEL_4;
        // P5.4 out
        P5DIR |= P5DIR_4;
        // CS->H for testing
        P5OUT |= P5OUT_4;
       
        //Baud rate registers: SMCLK/4
        U0BR1 = u0br_1;
        U0BR0 = u0br_0;
        U0MCTL = u0_mctl;

        // U0CTL programming
        // SW reset; 8-bits
        U0CTL |= SWRST + CHAR;
        // Idle line protocol
        U0CTL &= ~MM;
        // UART mode
        U0CTL &= ~SYNC;
        // No loopback
        U0CTL &= ~LISTEN;
        // 1 Stop bit
        U0CTL &= ~SPB;
        // No parity
        U0CTL &= ~PENA;
       
        // U0TxCTL setup
        // Enable Start edge
        U0TCTL |= URXSE;
      
        // U0RCTL programming
        // Allow all addr+data
        U0RCTL |= URXWIE;
        // Reset Rx_error; just to make sure is OK
        //U0RCTL &= ~RXERR;
        // En. Int1
        IE1 |= URXIE0;


        P5OUT &= ~P5OUT_4;
        P5OUT |= P5OUT_4;
       
        // Enable Rx USART0
        ME1 |= URXE0;
         
        //IE2: UTXIE1 and URXIE1 disabled by SWRST
        //Clear SWRST for USART operation
        U0CTL &= ~SWRST;


       
        // Check char Rx  ?
        if((IFG1 & URXIFG0) == 1)
        {
           P3OUT |= P3OUT_7;
        }
      // Check if Data/Addr  Is it OK?
        if ((U0RCTL & RXWAKE) == 0)
        {
          // Store U0RXBUF to RAM
          *((unsigned int*)(rx_ram_adr)) = (__READ U0RXBUF);  
        }
        else
        {
          // Error: Rx char is addr. Activate LED
          P3OUT |= P3OUT_6;    
        }

        // Disable Rx USART0
        ME1 &= ~URXE0;
     
       
    }

    Thanks in advance for your answers.

    Nicolae

  • Setup looks Ok. But you don’t have a for or while loop inside main, main will run only ones and will ends up somewhere in the sky.

    You enable interrupt but there is no interrupt service routine (ISR), same will end somewhere in the sky.

**Attention** This is a public forum