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.

ez430F2274 Serial Communications to PC

I am trying to make a switch from Arduino over to IT and trying to work my way through serial communication to my pc.  I am currently using this code

 

#include  "msp430x22x4.h"
#define LED1		BIT1
volatile unsigned int i;
void main(void)
{
  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
  P1DIR = 0xFF;                             // All P1.x outputs
  P1OUT = 0;                                // All P1.x reset
  P2DIR = 0xFF;                             // All P2.x outputs
  P2OUT = 0;                                // All P2.x reset
  P3SEL = 0x30;                             // P3.4,5 = USCI_A0 TXD/RXD
  P3DIR = 0xFF;                             // All P3.x outputs
  P3OUT = 0;                                // All P3.x reset
  P4DIR = 0xFF;                             // All P4.x outputs
  P4OUT = 0;                                // All P4.x reset
  UCA0CTL1 |= UCSSEL_1;                     // CLK = ACLK
  UCA0BR0 = 0x03;                           // 32kHz/9600 = 3.41
  UCA0BR1 = 0x00;                           //
  UCA0MCTL = UCBRS1 + UCBRS0;               // Modulation UCBRSx = 3
  UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
  while(1)
  {
  	IE2 |= UCA0TXIE;
  	P1OUT |= 0x01;                          // Set P1.0 LED on
    for (i = 5000; i > 0; i--);             // Delay
    P1OUT &= ~0x01; 
    for (i = 5000; i > 0; i--);
  }	
 
}
// Transmit the letter u to your heart's content :)
#pragma vector = USCIAB0TX_VECTOR
__interrupt void USCI0TX_ISR(void)
{
  UCA0TXBUF = 'u';
  
  IE2 &= ~UCA0TXIE;
}

So, my understanding is that the ACLK is taken from LFXT1 by default.  Is this correct?  I am using the code that comes in the examples folder so I am confused as to why it's not working.  I was thinking it has something to due with ACLK.  Should I have this pointing at the VLO?
Thank you for any input guys.

 

  • If you are using the eZ430-RF2500, this platform does not have a 32.768KHz crystal on the XIN/XOUT LFXT1 pins.

    Yes, ACLK is derived from LFXT1 by default.  This is found in the MSP430x2xx Family User's Guide in Section 5.

  • Thank you Brandon for the response.  What other options do I have to get this to work without the crystal?  Looking at a diagram that I have, ACLK can only be driven by VLO or LFXT1, this means I am out of luck without the crystal, doesn't it?  Reading, I found that it is pretty difficult to run UCOS16 = 0; so, I am off to the store to buy a crystal.  Again thanks for the help.

  • Sorry, another question.  How exactly do they get this to work then in the demo that is sent out with this kit?  They transmit the received data back to the demo gui.

  • I think I found it.  

    void COM_Init()
    {
      P3SEL |= 0x30;                            // P3.4,5 = USCI_A0 TXD/RXD
      UCA0CTL1 = UCSSEL_2;                      // SMCLK
    #if (BSP_CONFIG_CLOCK_MHZ_SELECT == 1)
      UCA0BR0 = 104;                            // 9600 from 1Mhz
      UCA0BR1 = 0;
      UCA0MCTL = UCBRS_1;
    #elif (BSP_CONFIG_CLOCK_MHZ_SELECT == 2)
      UCA0BR0 = 0xDA;                           // 9600 from 2Mhz
      UCA0BR1 = 0x0;
      UCA0MCTL = UCBRS_6;
    #elif (BSP_CONFIG_CLOCK_MHZ_SELECT == 4)
      UCA0BR0 = 0xA0;                           // 9600 from 4Mhz
      UCA0BR1 = 0x1;
      UCA0MCTL = UCBRS_6;
    #elif (BSP_CONFIG_CLOCK_MHZ_SELECT == 6)
      UCA0BR0 = 0x7B;                           // 9600 from 6Mhz
      UCA0BR1 = 0x2;
      UCA0MCTL = UCBRS_3;
    #elif (BSP_CONFIG_CLOCK_MHZ_SELECT == 8)
      UCA0BR0 = 0x41;                           // 9600 from 8Mhz
      UCA0BR1 = 0x3;
      UCA0MCTL = UCBRS_2;
    #elif (BSP_CONFIG_CLOCK_MHZ_SELECT == 10)
      UCA0BR0 = 0x79;                           // 9600 from 10Mhz
      UCA0BR1 = 0x4;
      UCA0MCTL = UCBRS_7;
    #elif (BSP_CONFIG_CLOCK_MHZ_SELECT == 12)
      UCA0BR0 = 0xE2;                           // 9600 from 12Mhz
      UCA0BR1 = 0x4;
      UCA0MCTL = 0;
    #elif (BSP_CONFIG_CLOCK_MHZ_SELECT == 16)
      UCA0BR0 = 0x82;                           // 9600 from 16Mhz
      UCA0BR1 = 0x6;
      UCA0MCTL = UCBRS_6;
    

    I can just take it from SMCLK.  Now I think I am starting to understand all the clock module stuff :).  Thanks again.

  • Charles Blakely said:
    I can just take it from SMCLK.  Now I think I am starting to understand all the clock module stuff

    Yep. Understanding the clock module is the key to many of the other hardware modules, as the clocks are used everywhere.

    P.s.: you can also output a clock signal on any port pin and route it back into XT1-in (in bypass mode). This way you can drive ACLK with an externally generated frequency (or internally generated by any othe rmeans, from a code loop to a CCR unit) and provide it as clock input to any other module. :)

  • Thank you for that bit of information.  I will try that when I get a little more comfortable working with the MSP430.  I currently have a working program, so I am pretty happy about that.

**Attention** This is a public forum