Jump to content
Sign in to follow this  
Kevink

msp430f149 Serial port example search

Recommended Posts

After searching for more than a week I've been unable to find an example of a serial port program for the 'f149 variant that can send and receive. I was able to get Don Binder's send only program to work fine but I had no luck with tx. It's not a matter of something being at the right frequency as there is no signal coming out at all. I'm new to msp430 but have used atmel parts and uC's since the late 1970's...

 

Most examples online use newer chips than the msp430f149 and it doesn't have calibration code so I did this:

 

//BCSCTL1 = CALBC1_1MHZ;
 //DCOCTL = CALDCO_1MHZ;
 //BCSCTL2 &= ~(DIVS_3);

    DCOCTL  = 0x70;
    BCSCTL1 = 0x73;
    BCSCTL2 = 0x88;

 

To get Don's code to work for the transmit only programs but it doesn't work for tx for some reason...

 

So anyone have a simple serial port tx/rx example for the msp430f149? I'm a crap programmer and it's a real struggle...

 

Thanks for any help,

 

Regards,

Kevin

VA3SU

Share this post


Link to post
Share on other sites

There are example in MSP430Ware that cover the F149. Taker a look in the folder MSPWare_2_40_00_37\examples\devices\MSP430F1xx\MSP430x13x_MSP430F14x_MSP430F15x_MSP430F16x_Code_Examples\C. For instance there's fet140_uart01_09600.c that does a simple echo.

Share this post


Link to post
Share on other sites

Thanks Fred, looking at changing fet140_uart01_09600.c now. Have to change it to the XT2 6MHz xtal that my system here has. Thanks again.

 

Regards,

Kevin

Share this post


Link to post
Share on other sites

I feel closer but... Still nothing comes out of the tx port as viewed by scope.

 

Here is my code. It is the TI fet140_uart01_9600.c changed by me to use the 6MHz xtal on XT2.

 

/* --COPYRIGHT--,BSD_EX
 
 * --/COPYRIGHT--*/
//******************************************************************************
//  MSP-FET430P140 Demo - USART0, UART 9600 Echo ISR, HF XTAL ACLK
//
//  Description: Echo a received character, RX ISR used. Normal mode is LPM0,
//  USART0 RX interrupt triggers TX Echo. Though not required, MCLK = LFXT1
//  ACLK = MCLK = UCLK0 = LFXT1 = 3.58MHz
//  Baud rate divider with 3.58Mhz XTAL @9600 = 3.58MHz/9600 = 372 (0174h)
//  //* An external 3.58Mhz XTAL on XIN XOUT is required for ACLK *//    
//
//                MSP430F149
//             -----------------
//         /|\|              XIN|-
//          | |                 | 3.58MHz
//          --|RST          XOUT|-
//            |                 |
//            |             P3.4|------------>
//            |                 | 9600 - 8N1
//            |             P3.5|<------------
//
//
//  M. Buccini
//  Texas Instruments Inc.
//  Feb 2005
//  Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.21A
//******************************************************************************

#include <msp430.h>

int main(void)
{
  volatile unsigned int i;
  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
  P3SEL |= 0x30;                            // P3.4,5 = USART0 TXD/RXD
  BCSCTL1 &= ~XT2OFF;                           // XT2= HF XTAL   <--------------------------- My change

  do                                                                                            <--------------------------- My change
  {
  IFG1 &= ~OFIFG;                           // Clear OSCFault flag<--------------------------- My change
  for (i = 0xFF; i > 0; i--);               // Time for flag to set<--------------------------- My change
  }
  while ((IFG1 & OFIFG));                   // OSCFault flag still set?<--------------------------- My change

  BCSCTL2 |= SELM_2;                        // MCLK= XT2 (safe)<--------------------------- My change
 
  ME1 |= UTXE0 + URXE0;                     // Enable USART0 TXD/RXD
  UCTL0 |= CHAR;                            // 8-bit character
  UTCTL0 |= SSEL0;                          // UCLK = ACLK
  UBR00 = 0x71;                             // 3.58Mhz/9600 - 372<--------------------------- My change
  UBR10 = 0x02;                             //<--------------------------- My change
  UMCTL0 = 0x00;                            // no modulation
  UCTL0 &= ~SWRST;                          // Initialize USART state machine
  IE1 |= URXIE0;                            // Enable USART0 RX interrupt

  __bis_SR_register(LPM0_bits + GIE);       // Enter LPM0 w/ interrupt
}

#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USART0RX_VECTOR
__interrupt void usart0_rx (void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USART0RX_VECTOR))) usart0_rx (void)
#else
#error Compiler not supported!
#endif
{
  while (!(IFG1 & UTXIFG0));                // USART0 TX buffer ready?
  TXBUF0 = RXBUF0;                          // RXBUF0 to TXBUF0
}

Share this post


Link to post
Share on other sites

Hello Spirilis

 

the line:

 

UTCTL0 |= SSEL0;                          // UCLK = ACLK

 

Is a TI original line but that might be clashing with my changes to the source of the clock... Any ideas on how to fix it?

 

Kevin

Share this post


Link to post
Share on other sites

TI example fet140_uart01_19200_2.c

 

Well after looking a little deeper I see there is a better TI serial port example for me to try, It's better because is uses XT2 as does my board. The only difference is that I need to change the xtal freq from 8MHz as in the example to 6 MHz as in my board. I changed my baud rate of my termina to 19200 as in the example and I changed

 

UBR00 = 0xA0;                             // 8Mhz/19200 ~ 417
UBR10 = 0x01;                             //
UMCTL0 = 0x00;                            // no modulation

 

to my setup:

 

UBR00 = 0x38;                             // 6Mhz/19200 ~ 312
UBR10 = 0x01;                             //
UMCTL0 = 0x00;                          // no modulation

 

And still no output...

Share this post


Link to post
Share on other sites

Murphy, a life long close personal friend of mine was with me today. The problem with my serial rx side of things was a blown Port 3 pin 5. I know this because I set all of port3 to toggle state and every pin on the port did but pin 5. Pin 5 is stuck high. I tried another board and all is good on that pin anyway... And now I get serial out!

 

Thanks to those that tried to help me

 

Kevin

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...