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.

UART communication

Other Parts Discussed in Thread: MSP430G2231

Hello,

   I hav written the program for UART but  I am not getting the data on serial port.


my program is as follwing.

 

#include  "msp430g2231.h"


#define     TXD                   BIT1                                       // TXD on P1.1
#define     Bitime                 104                                           //9600 Baud, SMCLK=1MHz (1MHz/9600)=104

unsigned char BitCnt;                                                             // Bit count, used when transmitting byte
unsigned int TXByte;                                                          // Value sent over UART when Transmit() is called
unsigned int uartUpdateTimer = 10;                                   // Loops until byte is sent
unsigned int i = 0;                                                         // Transmit value counter 33 = !
unsigned char name[10] = {"SKV ROXX"} ;  
                                                                                        // Function Definitions


void Transmit(void);

void main(void)
{
  WDTCTL = WDTPW + WDTHOLD;                    // Stop watchdog timer
 
  P1DIR |= 0x01;                                                       // Set P1.0 to output direction

   BCSCTL1 = CALBC1_1MHZ;                             // Set range
   DCOCTL = CALDCO_1MHZ;                          // SMCLK = DCO = 1MHz
  
   P1SEL |= TXD;                             
   P1DIR |= TXD;                                 
  _BIS_SR(LPM4_bits + GIE);                
  
  while(i!='\0')
  {
        P1OUT = 0x01;
        TXByte = name[i];    
          Transmit();            
        i++;
       
  }
 
}
// Function Transmits Character from TXByte

void Transmit()
{  
      CCTL0 = OUT;                                                            // TXD Idle as Mark
     TACTL = TASSEL_2 + MC_2;                                   // SMCLK, continuous mode  
      BitCnt = 0xA;                                                                // Load Bit counter, 8 bits + ST/SP
      CCR0 = TAR;    
      CCR0 += Bitime;                                                       // Set time till first bit
      TXByte |= 0x100;                                                        // Add stop bit to TXByte (which is logical 1)
       TXByte = TXByte << 1;                                             // Add start bit (which is logical 0)    
       CCTL0 =  CCIS0 + OUTMOD0 + CCIE;              // Set signal, intial value, enable interrupts
  while ( CCTL0 & CCIE );                                            // Wait for TX completion
  TACTL = TASSEL_2;                                                // SMCLK, timer off (for power consumption)
}

                                                                                     // Timer A0 interrupt service routine
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void)
  {
      CCR0 += Bitime;                                                  // Add Offset to CCR0  
      if ( BitCnt == 0)                                                    // If all bits TXed, disable interrupt  
          CCTL0 &= ~ CCIE ;
      else
      {  
          CCTL0 |=  OUTMOD2;                                 // TX Space  
       if (TXByte & 0x01)    
          CCTL0 &= ~ OUTMOD2;                              // TX Mark  
          TXByte = TXByte >> 1;  
          BitCnt --;
      }
}

**Attention** This is a public forum