RS232 MSP430 help

Hi,

I'm new to the world of MSP430 programming. The project I'm currently working on involves communication between an MSP430f149 and a PC using RS232. To start, I'm trying to write a simple routine to echo whatever is sent to the MSP430 via Hyperterminal. However, all attempts to send data have failed. I am using a Max3232 to connect to the serial port of a PC; when I connect the TX and RX ports, I indeed get echoing in Hyperterminal. This leads me to believe that the problem is caused by my code on the MSP. Specifically, I am not sure if I set the clock speed on the MSP correctly. I am trying to use the 32768Hz clock to generate a 2400 Baud rate. From the MSP430 User Guide, the various parameters are provided as follows: UBR00 = 0D; UBR10 = 00; UMCTL0 =

6B. However, a separate Baud rate calculator
formatting link
gave me: UBR00=0x0D; UBR10=0x00; UMCTL0=0x6D. I have tried both to no avail.

This is my routine. It should (at least in my mind) continually transmit 0x59 (Y) and be able to listen to interrupts.

#include

char temp; volatile int a; volatile int b; void main(void) {

unsigned int i; WDTCTL = WDTPW + WDTHOLD; // Stop WDT P3SEL |= 0x30; // P3.4,5 = USART0 TXD/RXD P3DIR |= 0x10; // P3.4 output direction _EINT(); // Enable interrupts

BCSCTL1 = 0; // ACLK = LFXT1 = HF XTAL BCSCTL2 |= SELM1+SELM0;; // MCLK = LFXT1 (safe) do { IFG1 &= ~OFIFG; // Clear OSCFault flag for (i = 0xFF; i > 0; i--); // Time for flag to set } while ((IFG1 & OFIFG) != 0); // OSCFault flag still set?

UCTL0 = SWRST; UCTL0 |= CHAR; // 8-bit character UTCTL0 |= SSEL0; // UCLK = ACLK UBR00 = 0x0D; UBR10 = 0x00; UMCTL0 = 0x6B; UCTL &= ~SWRST; IFG1 &= ~(UTXIFG0 | URXIFG0); ME1 |= UTXE0 + URXE0; // Enable USART0 TXD/RXD IE1 |= URXIE0; // Enable USART0 RX interrupt a = 1;

for (;;) { // while ((IFG1 & UTXIFG0) == 0); // TXBUF0 = 0x59; } }

#pragma vector=USART0RX_VECTOR __interrupt void intUart0Rx(void) { b = 1; while ((IFG1 & UTXIFG0) == 0); // USART0 TX buffer ready? temp = 1; TXBUF0 = RXBUF0; // RXBUF0 to TXBUF0 }

Regarding the interrupt, I am using Live Watch in IAR Workshop to monitor the status of variables and it never enters the ISR.

I have been using an oscilloscope to measure voltage changes. I get a constant 3V from the transmit port and I have yet to pick up any type of transmit. On the other hand, when I type something in Hyperterminal, I get a nice periodic voltage signature at on the ports.

Regarding the clocks, is there an internal built-in 32768Hz crystal or do I need to connect one to the XIN/XOUT? Is there any way to test if such a crystal exists? Am I accessing the 32768 clock correctly?

For reference, I am setting Hyperterminal to:

2400bps 8 bit chars parity: none flow control: Off Stop bit: 1 bit

Any help would be greatly appreciated. Thanks!

-Bryce

Reply to
kungling777
Loading thread data ...

See the data sheet...

Write a very simple program that toggles an I/O pin in a tight loop. Look at that pin with a scope. If you can figure out how many clocks your loop should take, you might even be able to determine the clock frequency.

Reply to
cs_posting

You have to connect a crystal.

Do you have a debugger? Connect using debugger and as suggested below write a simple program to toggle pin or something. Debugger generates so getting the toggle working shouldn't be much of a problem. If on removing the debugger and supplying clock the toggle continues then you are on your way. btw there aren't many wrong ways of conncting the crystal so I am sure if you have attached one then it should be correct

Frequency: It has PLL inside to frequency is selectable

Reply to
Rohan

Hi,

This post had helped me through earlier. Do post back if you are still not able to figure out. Will try to post some code

formatting link

Rohan

Reply to
Rohan

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.