简体   繁体   English

将腻子数据导入MSP430

[英]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. 我试图对两个MSP430进行编程,以通过PuTTY实质上是即时消息,但无法弄清楚如何在没有调试器的情况下将键入的信息存储到MSP430上。 I'm using CCS and it's an MSP430 F2274. 我正在使用CCS,它是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. 我有一个程序,用户可以在一个MSP430的按钮上输入莫尔斯电码,然后通过以下方法成功将另一个MSP430的PuTTY输出到PuTTY。

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? 有人可以使用类似的设置发送相反的代码(将信息键入MSP430)吗? thanks. 谢谢。

I used picocom: 我使用了picocom:

$ picocom -r -b 9600 /dev/ttySxxxx

Code for UART initialization: UART初始化代码:

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(): 覆盖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. 然后,您可以简单地调用printf(...)将文本从MSP430输出到串行端口。

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: 如果您仍然希望将putchar()prtinf()调试用途-打印到调试器的调试窗口中,则可以使用单独的read功能:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM