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.
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
#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 ); } }
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
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
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
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
**Attention** This is a public forum