Kevink 2 Posted January 15, 2016 Share Posted January 15, 2016 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 Quote Link to post Share on other sites
Fred 453 Posted January 15, 2016 Share Posted January 15, 2016 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. Quote Link to post Share on other sites
Kevink 2 Posted January 15, 2016 Author Share Posted January 15, 2016 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 Quote Link to post Share on other sites
Kevink 2 Posted January 15, 2016 Author Share Posted January 15, 2016 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} Quote Link to post Share on other sites
Kevink 2 Posted January 15, 2016 Author Share Posted January 15, 2016 UBR00 and UBR10 were changed as per a calculator for 6 MHz. and 9600 baud. Quote Link to post Share on other sites
spirilis 1,265 Posted January 15, 2016 Share Posted January 15, 2016 Is there any BCSCTL settings to change SMCLK? The peripherals usually use SMCLK. edit: There's a line in your code indicating you're switching the USART clock to ACLK. That doesn't sound right... Quote Link to post Share on other sites
Kevink 2 Posted January 16, 2016 Author Share Posted January 16, 2016 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 Quote Link to post Share on other sites
Kevink 2 Posted January 16, 2016 Author Share Posted January 16, 2016 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 ~ 417UBR10 = 0x01; //UMCTL0 = 0x00; // no modulation to my setup: UBR00 = 0x38; // 6Mhz/19200 ~ 312UBR10 = 0x01; //UMCTL0 = 0x00; // no modulation And still no output... Quote Link to post Share on other sites
Kevink 2 Posted January 16, 2016 Author Share Posted January 16, 2016 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 bluehash 1 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.