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 msp4305529

Other Parts Discussed in Thread: MSP-EXP430F5529LP

Dear sir,

I am trying with msp4305529 UART program,but i am not getting the output on hyperterminal.Please go throgh the attachment.

thank you

prgm.txt
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "msp430.h"
char data1[]={"lets play \r\n"};
char data2[]={"hello guys how are you \r\n"};
void uart_init( void )
{
P3SEL |= BIT3+BIT4; // P3.3,4 = USCI_A0 TXD/RXD
UCA0CTL1 |= UCSWRST; // **Put state machine in reset**
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 9; // 1MHz 115200 (see User's Guide)
UCA0BR1 = 0; // 1MHz 115200
UCA0MCTL |= UCBRS_1 + UCBRF_0; // Modulation UCBRSx=1, UCBRFx=0
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt
}//Initialize USCI state machine
void uart_send_byte( unsigned char data )
{
while (!(UCA0IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = data;//The transmit data buffer holds the data waiting to be moved into the transmit shift register
}
void main(void)
{
unsigned int i=0,j=0;
WDTCTL = WDTPW + WDTHOLD; // Stop Watchdog timer
uart_init();
while( 1 )
{
for (i=0; i<14; i++)
{
uart_send_byte( data1[i] );
}
for(j=0;j<25;j++)
{
uart_send_byte(data2[j]);
}
__bis_SR_register( LPM3_bits + GIE );
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Hi Mohammed!

    I will insert your source code using the Syntaxhighlighter. Please use it next time when posting code.

    #include "msp430.h"
    
    char data1[] = {"lets play \r\n"};
    char data2[] = {"hello guys how are you \r\n"};
    
    void uart_init( void )
    {
      P3SEL |= BIT3+BIT4;                       // P3.3,4 = USCI_A0 TXD/RXD
      UCA0CTL1 |= UCSWRST;                      // **Put state machine in reset**
      UCA0CTL1 |= UCSSEL_2;                     // SMCLK
      UCA0BR0 = 9;                              // 1MHz 115200 (see User's Guide)
      UCA0BR1 = 0;                              // 1MHz 115200
      UCA0MCTL |= UCBRS_1 + UCBRF_0;            // Modulation UCBRSx=1, UCBRFx=0
      UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
      UCA0IE |= UCRXIE;                         // Enable USCI_A0 RX interrupt
    }                                           // Initialize USCI state machine
    
    void uart_send_byte( unsigned char data )
    {
      while( !(UCA0IFG&UCTXIFG) );              // USCI_A0 TX buffer ready?
      UCA0TXBUF = data;                         // The transmit data buffer holds the data waiting to be moved into the transmit shift register
    }
    
    void main( void )
    {
      unsigned int i = 0, j = 0;
    
      WDTCTL = WDTPW + WDTHOLD;                 // Stop Watchdog timer
    
      uart_init();
    
      while( 1 )
      {
        for( i = 0; i < 14; i++ )
        {
          uart_send_byte( data1[i] );
        }
    
        for( j = 0; j < 25; j++ )
        {
          uart_send_byte( data2[j] );
    
        }
    
        __bis_SR_register( LPM3_bits + GIE );
      }
    }

    Is there more code? I see you enable the interrupts for RX, but there is no handler for it.

    Dennis

  • The default SMCLK derived from the DCO is not very accurate. Either use a crystal as clock source, or try reducing the baud rate to 2400 or so.
  • Hello sir,

    i changed the baud rate to 2400 by varying ,
    UCA0BR0 = 0x0D;
    UCA0BR1 = 0;

    but still not getting on hyper terminal.
    please help me in this regard.

    thank you
  • Do you see anything on those pins with an oscilloscope or logic analyzer?

    Are you sure you're using the correct pins? (There are multiple UARTs. How did you connect it to HyperTerminal?)

  • I would first check my SMCLK. You can measure it with an oscilloscope at P2.2 when adding the following lines to your code:

    P2DIR |= BIT2;
    P2SEL |= BIT2;

    Dennis

  • ok sir ,but when i set the baud rate to 2400 , i am getting junk values in hyper terminal.
  • Then I guess you have to use a crystal.
  • No sir,it is not transmitting but when press the jumpers with little bit pressure ,then it is giving junk values.
    then may i know how to involve the crystals and by using P2DIR |= BIT2;
    P2SEL |= BIT2; still i am facing problem.

    can you just share the code if u have like this or please do edinting my code and send me back.

    thank u
  • MOHAMMAD NASEER M N said:
    then may i know how to involve the crystals and by using P2DIR |= BIT2;
    P2SEL |= BIT2;

    This has nothing to do with a crystal, it simply outputs your internal SMCLK (your source for the UART) to an output pin to measure it's exact frequency.

    Dennis

  • thats all fine ,when i run the program step by step,it enters all my lines in the code and there is no errors at all.May i get the know where my program going wrong ...? is there any jumpers to change its position..(i think no)..?is there any baudrate problem, as i changed from 1200 to 115200 but not getting output.

    thank you
  • Which hardware are you working with? The red MSP-EXP430F5529LP LaunchPad? You did not say anything about it.
  • sorry sir,i think you dint notice and i said in the begining of our conversation that i am using (red) MSP-EXP430F5529LP.

    thank you
  • MOHAMMAD NASEER M N said:
    sorry sir,i think you dint notice and i said in the begining of our conversation that i am using (red) MSP-EXP430F5529LP.

    No, sorry, cannot see where you did that.

    Anyway - if you are using the MSP-EXP430F5529LP, then the UART pins connected to the Application UART which comes with the USB connection, are P4.4 (UCA1TXD) and P4.5 (UCA1RXD). You are using UCA0.

    Dennis

  • Hi dennis,
    thanks a lot for ur continuous support,finally i got the output.
  • Glad to hear it works!

    Dennis
  • hi dennis,
    I want to do some project on this launchpad and what and all i can do with this.Do u have any idea.If so, please share with me.
    thank you
  • helo Dennis sir,

    Waiting for your reply.

    thank you

**Attention** This is a public forum