Lexie
Lexie

Reputation: 11

PuTTY data into MSP430

I am attempting to program two MSP430s to essentially instant message through PuTTY, but cannot figure out how to get typed information onto the MSP430 without the debugger. I'm using CCS and it's an MSP430 F2274. I have one program in which the user inputs in morse code on the button on one MSP430 that successfully outputs to PuTTY off another MSP430 via the following method.

void displayString(char array[], char size) {
    WDTCTL = WDTPW + WDTHOLD;            // Disable WDT
    DCOCTL = CALDCO_8MHZ;                // Load 8MHz constants
    BCSCTL1 = CALBC1_8MHZ;               //
    P3SEL |= 0x30;                       // P3.4,5 = USCI_A0 TXD/RXD
    UCA0CTL1 |= UCSSEL_2;                // SMCLK
    UCA0BR0 = 0x41;                      // 8MHz 9600
    UCA0BR1 = 0x03;                      // 8MHz 9600
    UCA0MCTL = UCBRS1;                   // Modulation UCBRSx = 2
    UCA0CTL1 &= ~UCSWRST;                // **Initialize USCI state

  int count;
  for(count=0; count<size; count++){
    while (!(IFG2&UCA0TXIFG));              // USCI_A0 TX buffer ready?
    UCA0TXBUF = array[count];               // TX -> RXed character
  }
}

Can someone send code that does the reverse (types information onto MSP430) with a similar setup? thanks.

Upvotes: 1

Views: 1683

Answers (2)

Ruslan Gerasimov
Ruslan Gerasimov

Reputation: 1782

If you still want to leave putchar() and prtinf() for debug purpose - printing into debug window of debugger, then you can have separate read function:

unsigned char ReadByteUCA_UART(void)    
{   
    //while ((IFG2&UCA0RXIFG)==0);  // wait for RX buffer (full)   
    while(UCA0STAT&UCBUSY);   
    return (UCA0RXBUF);   
} 

Upvotes: 0

hasan
hasan

Reputation: 638

I used picocom:

$ picocom -r -b 9600 /dev/ttySxxxx

Code for UART initialization:

void uart_setup()
{
  // Configure UART pins
  P2SEL1 |= BIT0 + BIT1;
  P2SEL0 &= ~(BIT0 + BIT1);

  // Configure UART 0
  UCA0CTL1 |= UCSWRST; // perform reset
  UCA0CTL1 = UCSSEL_1;                      // Set ACLK = 32768 as UCBRCLK
  UCA0BR0 = 3;                              // 9600 baud
  UCA0BR1 = 0; 
  UCA0MCTLW |= 0x5300;                      // 32768/9600 - INT(32768/9600)=0.41
                                            // UCBRSx value = 0x53 (See UG)
  UCA0CTL1 &= ~UCSWRST;                     // release from reset
  //UCA0IE |= UCRXIE;                         // Enable RX interrupt
}

Override putchar():

int putchar(int c)
{
  if (c == '\n') putchar('\r');
  while (!(UCA0IFG & UCTXIFG));
  UCA0TXBUF = c;
  return 0;
}

And then you can simple call printf(...) to output text from the MSP430 to the serial port.

Upvotes: 1

Related Questions