Reply by Microbit March 10, 20072007-03-10
Much appreciated, good to be "exonerated" :-)
I hope the scepticism I received might be reconsidered !

I actually owe you a good apology....
I looked through the thread again and noticed this :

> This couple of lines I added to try and get the TX pin to send anything.
> This of course didn't work.

I thought you were referring to my suggestion about the P3DIR.
I now realise that you were referring to the - obviously - test loop you
put in to _directly_ send data to TXD.
This makes sense now : "This of course didn't work".

I should have known really, because you referred to "lines" - not "line"
(which would then refer to setting TXD in P3DIR).
Again, I apologise for the mix-up !!!!

Anyway, glad to hear it's working now - and that my assertion has been confirmed.
I still have a F149 tray of chips that need P3DIR set, that's why I just leave the P3DIR line in,
just in case different rev is used.

If others want to go their own way, that's their prerogative I guess......

Best Regards,
Kris

-----Original Message-----
From: m... [mailto:m...] On Behalf Of matthewolsthoorn
Sent: Sunday, 11 March 2007 2:08 AM
To: m...
Subject: [msp430] Re: UART Response Problem

Just an update. I've Tried setting the port 3 directions like
suggested and it seems to be working now. Thanks for the help guys.
I used the same code as posted earlier. Just changes the Port3 directions.

--- In m..., "matthewolsthoorn"
wrote:
>
> Hi,
>
> I've been trying to setup the UART on my MSP430f149 using the sample
> code given. I haven't had much luck. I'm not sure exactly what's going
> on. The code I used is exactly the C example code provided by TI shown
> below. However, the interrupt never gets called. (I've send data
> directly into the receive pin). I tried to just pass data into the
> transmit pin but nothing ever shows up on the pin (I used an
> oscilloscope).
>
> Is there some setup that I need to set other than these software parts?
> Are there any other pins that need to be used?
>
> This is what I've done:
> Powered the Micro
> Places a 8Mhz oscillator
> Observed the transmit pin for any activity
>
> So far I've not managed to get it to work. What did I miss?
> #include void main(void)
> {
> volatile unsigned int i;
> WDTCTL = WDTPW + WDTHOLD; // Stop WDT
> P3SEL |= 0x30; // P3.4,5 = USART0 TXD/RXD
>
> BCSCTL1 &= ~XT2OFF; // XT2on
>
> do
> {
> IFG1 &= ~OFIFG; // Clear OSCFault flag
> for (i = 0xFF; i > 0; i--); // Time for flag to set
> }
> while ((IFG1 & OFIFG)); // OSCFault flag still set?
>
> BCSCTL2 |= SELM_2 + SELS; // MCLK = SMCLK = XT2 (safe)
> ME1 |= UTXE0 + URXE0; // Enable USART0 TXD/RXD
> UCTL0 |= CHAR; // 8-bit character
> UTCTL0 |= SSEL1; // UCLK = SMCLK
> UBR00 = 0x45; // 8MHz 115200
> UBR10 = 0x00; // 8MHz 115200
> UMCTL0 = 0x00; // 8MHz 115200 modulation
> UCTL0 &= ~SWRST; // Initialize USART state
> machine
> IE1 |= URXIE0; // Enable USART0 RX
interrupt
>
> _BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/ interrupt
>
> while (1)
> {
> TXBUF0 |=0xF0;
> }
> }
>
> #pragma vector=UART0RX_VECTOR
> __interrupt void usart0_rx (void)
> {
> while (!(IFG1 & UTXIFG0)); // USART0 TX buffer ready?
> TXBUF0 = RXBUF0; // RXBUF0 to TXBUF0
> }
>

Yahoo! Groups Links

Beginning Microcontrollers with the MSP430

Reply by Microbit March 10, 20072007-03-10
Hi OCY, David et al,

To set the record straight all the way now :

> Question 1: What silicon revision of F149 are you using? I do not
> think this is important.

Well, it is....

> Question 2: Are you sure the 8MHz crystal is oscillating? Do NOT look
> at pin 52 or 53.

Why not ? A minimal decent CRO probe will nicely show the waveform.

> Set P5SEL:BIT5 to 1 and look at pin 49. You should
> see SMCLK there.
> (You do not need to set P5DIR:BIT5.)

Wrong too !!
In earlier revs you DO have to set P5DIR. I remember having to do that with those F149s !!

Conclusion :
If you can _guarantee_ that only F16XX will be used, no worries.
But if you need to drop in F149, I'd revisit my code ......

I was a little irritated that "newbies" to MSP430 (from my time point of view) asserted "facts"
about MSP430 that are clearly wrong.
That's a bit of an unfair equation to me, considering I was obviosuly using MSP430 a LONG time
before the critics on here were....

Best Regards,
Kris

-----Original Message-----
From: m... [mailto:m...] On Behalf Of old_cow_yellow
Sent: Friday, 9 March 2007 7:10 AM
To: m...
Subject: [msp430] Re: UART Response Problem

Matt,

I did not respond to your original post because I cannot figure out
what went wrong. Other then the useless while (1) loop at the end,
the code seems okay to me. I have two questions and one suggestion
(if you are still stuck):

Question 1: What silicon revision of F149 are you using? I do not
think this is important. Just to satisfy my curiosity.

Question 2: Are you sure the 8MHz crystal is oscillating? Do NOT look
at pin 52 or 53. Set P5SEL:BIT5 to 1 and look at pin 49. You should
see SMCLK there. (You do not need to set P5DIR:BIT5.)

Suggestion: Solve one problem at a time. The modified code below
should show TXD0 as a continous square wave of about 57.6 kHz (i.e.,
alternating 0 and 1 at 115.2 kb/s.)

#include

void main(void)
{
volatile unsigned int i;
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P3SEL |= 0x30; // P3.4,5 = USART0 TXD/RXD

BCSCTL1 &= ~XT2OFF; // XT2on

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

BCSCTL2 |= SELM_2 + SELS; // MCLK = SMCLK = XT2 (safe)
ME1 |= UTXE0 + URXE0; // Enable USART0 TXD/RXD
UCTL0 |= CHAR; // 8-bit character
UTCTL0 |= SSEL1; // UCLK = SMCLK
UBR00 = 0x45; // 8MHz 115200
UBR10 = 0x00; // 8MHz 115200
UMCTL0 = 0x00; // 8MHz 115200 modulation
UCTL0 &= ~SWRST; // Initialize USART state machine

// The above are your original code.
// The rest of your original code is cut.
// What follows is new.

P5SEL |= BIT5; //show SMCLK at pin 56
while (1)
{
if (IFG1 & UTXIFG0) TXBUF0 = 0x55; //TXD0 at pin 32
}

}

--- In m..., "matthewolsthoorn"
wrote:
>
> Hi,
>
> I've been trying to setup the UART on my MSP430f149 using the sample
> code given. I haven't had much luck. I'm not sure exactly what's
going
> on. The code I used is exactly the C example code provided by TI
shown
> below. However, the interrupt never gets called. (I've send data
> directly into the receive pin). I tried to just pass data into the
> transmit pin but nothing ever shows up on the pin (I used an
> oscilloscope).
>
> Is there some setup that I need to set other than these software
parts?
> Are there any other pins that need to be used?
>
> This is what I've done:
> Powered the Micro
> Places a 8Mhz oscillator
> Observed the transmit pin for any activity
>
> So far I've not managed to get it to work. What did I miss?
> #include void main(void)
> {
> volatile unsigned int i;
> WDTCTL = WDTPW + WDTHOLD; // Stop WDT
> P3SEL |= 0x30; // P3.4,5 = USART0
TXD/RXD
>
> BCSCTL1 &= ~XT2OFF; // XT2on
>
> do
> {
> IFG1 &= ~OFIFG; // Clear OSCFault flag
> for (i = 0xFF; i > 0; i--); // Time for flag to set
> }
> while ((IFG1 & OFIFG)); // OSCFault flag still
set?
>
> BCSCTL2 |= SELM_2 + SELS; // MCLK = SMCLK = XT2
(safe)
> ME1 |= UTXE0 + URXE0; // Enable USART0 TXD/RXD
> UCTL0 |= CHAR; // 8-bit character
> UTCTL0 |= SSEL1; // UCLK = SMCLK
> UBR00 = 0x45; // 8MHz 115200
> UBR10 = 0x00; // 8MHz 115200
> UMCTL0 = 0x00; // 8MHz 115200
modulation
> UCTL0 &= ~SWRST; // Initialize USART
state
> machine
> IE1 |= URXIE0; // Enable USART0 RX
interrupt
>
> _BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/
interrupt
>
> while (1)
> {
> TXBUF0 |=0xF0;
> }
> }
>
> #pragma vector=UART0RX_VECTOR
> __interrupt void usart0_rx (void)
> {
> while (!(IFG1 & UTXIFG0)); // USART0 TX buffer
ready?
> TXBUF0 = RXBUF0; // RXBUF0 to TXBUF0
> }
>

Yahoo! Groups Links
Reply by matthewolsthoorn March 10, 20072007-03-10
Just an update. I've Tried setting the port 3 directions like
suggested and it seems to be working now. Thanks for the help guys.
I used the same code as posted earlier. Just changes the Port3 directions.

--- In m..., "matthewolsthoorn"
wrote:
>
> Hi,
>
> I've been trying to setup the UART on my MSP430f149 using the sample
> code given. I haven't had much luck. I'm not sure exactly what's going
> on. The code I used is exactly the C example code provided by TI shown
> below. However, the interrupt never gets called. (I've send data
> directly into the receive pin). I tried to just pass data into the
> transmit pin but nothing ever shows up on the pin (I used an
> oscilloscope).
>
> Is there some setup that I need to set other than these software parts?
> Are there any other pins that need to be used?
>
> This is what I've done:
> Powered the Micro
> Places a 8Mhz oscillator
> Observed the transmit pin for any activity
>
> So far I've not managed to get it to work. What did I miss?
> #include void main(void)
> {
> volatile unsigned int i;
> WDTCTL = WDTPW + WDTHOLD; // Stop WDT
> P3SEL |= 0x30; // P3.4,5 = USART0 TXD/RXD
>
> BCSCTL1 &= ~XT2OFF; // XT2on
>
> do
> {
> IFG1 &= ~OFIFG; // Clear OSCFault flag
> for (i = 0xFF; i > 0; i--); // Time for flag to set
> }
> while ((IFG1 & OFIFG)); // OSCFault flag still set?
>
> BCSCTL2 |= SELM_2 + SELS; // MCLK = SMCLK = XT2 (safe)
> ME1 |= UTXE0 + URXE0; // Enable USART0 TXD/RXD
> UCTL0 |= CHAR; // 8-bit character
> UTCTL0 |= SSEL1; // UCLK = SMCLK
> UBR00 = 0x45; // 8MHz 115200
> UBR10 = 0x00; // 8MHz 115200
> UMCTL0 = 0x00; // 8MHz 115200 modulation
> UCTL0 &= ~SWRST; // Initialize USART state
> machine
> IE1 |= URXIE0; // Enable USART0 RX
interrupt
>
> _BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/ interrupt
>
> while (1)
> {
> TXBUF0 |=0xF0;
> }
> }
>
> #pragma vector=UART0RX_VECTOR
> __interrupt void usart0_rx (void)
> {
> while (!(IFG1 & UTXIFG0)); // USART0 TX buffer ready?
> TXBUF0 = RXBUF0; // RXBUF0 to TXBUF0
> }
>
Reply by Microbit March 9, 20072007-03-09
Hi OCY,

Old habits die hard I guess :-)

> N, O, and Q do not need P3DIR.3 to be set either. I do not know about
> revisions A through K. My speculation is that they are the same in
> this respect. But that is just my speculation.

I've never bothered checking where the change would be, but I can assure you that some of those
revisions will need P3DIR for TXD to work.
In fact that's the exception to the rule anyway. MSP430 special functions generally dont drive
the I/O DIR settings, you have to do that yourself.

I never rely on POR values in init code, and I conversely don't rely on this "P3SEL guarantees
that P3DIR is set" business either.
It's just one instruction, and I think it's not worth the risk, I simply still use the P3DIR
instruction.
Better safe than sorry, but that's me.

I've used F149 ever since it was hardly an engineering sample, so I consider myself to know the
pitfalls by now..

Best Regards,
Kris

-----Original Message-----
From: m... [mailto:m...] On Behalf Of old_cow_yellow
Sent: Friday, 9 March 2007 3:27 AM
To: m...
Subject: [msp430] Re: UART Response Problem

I already gave you my short answer: Do not worry.

Here is my long answer. The current silicon revision of MSP430F1610
is B. For both revision A and B, when you set P3SEL.3 there is no
need to set P3DIR.3.

There are lots of silicon revisions for MSP430F149. Revisions L, M,
N, O, and Q do not need P3DIR.3 to be set either. I do not know about
revisions A through K. My speculation is that they are the same in
this respect. But that is just my speculation.

--- In m..., mago Umandam wrote:
>
> Is this is true to all MSP430? that aside from setting the P3SEL,
we need to set the P3DIR for TXD? i worry that my previous project
may suddenly stop working.:) I used MSP430F1610 and i didnt set the
P3DIR for the TXD though it worked. :D
Reply by old_cow_yellow March 8, 20072007-03-08
Matt,

I did not respond to your original post because I cannot figure out
what went wrong. Other then the useless while (1) loop at the end,
the code seems okay to me. I have two questions and one suggestion
(if you are still stuck):

Question 1: What silicon revision of F149 are you using? I do not
think this is important. Just to satisfy my curiosity.

Question 2: Are you sure the 8MHz crystal is oscillating? Do NOT look
at pin 52 or 53. Set P5SEL:BIT5 to 1 and look at pin 49. You should
see SMCLK there. (You do not need to set P5DIR:BIT5.)

Suggestion: Solve one problem at a time. The modified code below
should show TXD0 as a continous square wave of about 57.6 kHz (i.e.,
alternating 0 and 1 at 115.2 kb/s.)

#include

void main(void)
{
volatile unsigned int i;
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P3SEL |= 0x30; // P3.4,5 = USART0 TXD/RXD

BCSCTL1 &= ~XT2OFF; // XT2on

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

BCSCTL2 |= SELM_2 + SELS; // MCLK = SMCLK = XT2 (safe)
ME1 |= UTXE0 + URXE0; // Enable USART0 TXD/RXD
UCTL0 |= CHAR; // 8-bit character
UTCTL0 |= SSEL1; // UCLK = SMCLK
UBR00 = 0x45; // 8MHz 115200
UBR10 = 0x00; // 8MHz 115200
UMCTL0 = 0x00; // 8MHz 115200 modulation
UCTL0 &= ~SWRST; // Initialize USART state machine

// The above are your original code.
// The rest of your original code is cut.
// What follows is new.

P5SEL |= BIT5; //show SMCLK at pin 56
while (1)
{
if (IFG1 & UTXIFG0) TXBUF0 = 0x55; //TXD0 at pin 32
}

}

--- In m..., "matthewolsthoorn"
wrote:
>
> Hi,
>
> I've been trying to setup the UART on my MSP430f149 using the sample
> code given. I haven't had much luck. I'm not sure exactly what's
going
> on. The code I used is exactly the C example code provided by TI
shown
> below. However, the interrupt never gets called. (I've send data
> directly into the receive pin). I tried to just pass data into the
> transmit pin but nothing ever shows up on the pin (I used an
> oscilloscope).
>
> Is there some setup that I need to set other than these software
parts?
> Are there any other pins that need to be used?
>
> This is what I've done:
> Powered the Micro
> Places a 8Mhz oscillator
> Observed the transmit pin for any activity
>
> So far I've not managed to get it to work. What did I miss?
> #include void main(void)
> {
> volatile unsigned int i;
> WDTCTL = WDTPW + WDTHOLD; // Stop WDT
> P3SEL |= 0x30; // P3.4,5 = USART0
TXD/RXD
>
> BCSCTL1 &= ~XT2OFF; // XT2on
>
> do
> {
> IFG1 &= ~OFIFG; // Clear OSCFault flag
> for (i = 0xFF; i > 0; i--); // Time for flag to set
> }
> while ((IFG1 & OFIFG)); // OSCFault flag still
set?
>
> BCSCTL2 |= SELM_2 + SELS; // MCLK = SMCLK = XT2
(safe)
> ME1 |= UTXE0 + URXE0; // Enable USART0 TXD/RXD
> UCTL0 |= CHAR; // 8-bit character
> UTCTL0 |= SSEL1; // UCLK = SMCLK
> UBR00 = 0x45; // 8MHz 115200
> UBR10 = 0x00; // 8MHz 115200
> UMCTL0 = 0x00; // 8MHz 115200
modulation
> UCTL0 &= ~SWRST; // Initialize USART
state
> machine
> IE1 |= URXIE0; // Enable USART0 RX
interrupt
>
> _BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/
interrupt
>
> while (1)
> {
> TXBUF0 |=0xF0;
> }
> }
>
> #pragma vector=UART0RX_VECTOR
> __interrupt void usart0_rx (void)
> {
> while (!(IFG1 & UTXIFG0)); // USART0 TX buffer
ready?
> TXBUF0 = RXBUF0; // RXBUF0 to TXBUF0
> }
>
Reply by old_cow_yellow March 8, 20072007-03-08
I already gave you my short answer: Do not worry.

Here is my long answer. The current silicon revision of MSP430F1610
is B. For both revision A and B, when you set P3SEL.3 there is no
need to set P3DIR.3.

There are lots of silicon revisions for MSP430F149. Revisions L, M,
N, O, and Q do not need P3DIR.3 to be set either. I do not know about
revisions A through K. My speculation is that they are the same in
this respect. But that is just my speculation.

--- In m..., mago Umandam wrote:
>
> Is this is true to all MSP430? that aside from setting the P3SEL,
we need to set the P3DIR for TXD? i worry that my previous project
may suddenly stop working.:) I used MSP430F1610 and i didnt set the
P3DIR for the TXD though it worked. :D
>
> mago
>
> Microbit wrote:
> Good luck with your code ....
> One day a customer will be using (old stock) F149 instead and it'll
be :
> "Gosh, the serial just stopped working, we just can't figure out
why...".
>
> Two days of frantic debugging later it'll sound like this :
> "Oops, I thought that the P3DIR register didn't need setting its
bits for the TXD pin(s)..."
>
> And all for the sake of 1 line of ASM or C...
> Well, I guess we'll never know now :-)
>
> Best Regards,
> Kris
> -----Original Message-----
> From: m... [mailto:m...] On
Behalf Of David Collier
> Sent: Wednesday, 7 March 2007 10:13 PM
> To: m...
> Subject: RE: [msp430] UART Response Problem
>
> Hmmmm
>
> I thought that for the UART pins selecting them as special
specifically
> DID set the IO direction.... in the 169/1611 anyway.
>
> see pin logic diagram on page 53 of msp430f1611.pdf
>
> David
>
> Yahoo! Groups Links
>
> ---------------------------------
> Need Mail bonding?
> Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users.
>
>
>
Reply by old_cow_yellow March 7, 20072007-03-07
Do not worry. You are doing fine.

--- In m..., mago Umandam wrote:
>
> Is this is true to all MSP430? that aside from setting the P3SEL,
we need to set the P3DIR for TXD? i worry that my previous project
may suddenly stop working.:) I used MSP430F1610 and i didnt set the
P3DIR for the TXD though it worked. :D
>
> mago
>
> Microbit wrote:
> Good luck with your code ....
> One day a customer will be using (old stock) F149 instead and it'll
be :
> "Gosh, the serial just stopped working, we just can't figure out
why...".
>
> Two days of frantic debugging later it'll sound like this :
> "Oops, I thought that the P3DIR register didn't need setting its
bits for the TXD pin(s)..."
>
> And all for the sake of 1 line of ASM or C...
> Well, I guess we'll never know now :-)
>
> Best Regards,
> Kris
> -----Original Message-----
> From: m... [mailto:m...] On
Behalf Of David Collier
> Sent: Wednesday, 7 March 2007 10:13 PM
> To: m...
> Subject: RE: [msp430] UART Response Problem
>
> Hmmmm
>
> I thought that for the UART pins selecting them as special
specifically
> DID set the IO direction.... in the 169/1611 anyway.
>
> see pin logic diagram on page 53 of msp430f1611.pdf
>
> David
>
> Yahoo! Groups Links
>
>
>
>
> ---------------------------------
> Need Mail bonding?
> Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users.
>
>
>
Reply by mago Umandam March 7, 20072007-03-07
Is this is true to all MSP430? that aside from setting the P3SEL, we need to set the P3DIR for TXD? i worry that my previous project may suddenly stop working.:) I used MSP430F1610 and i didnt set the P3DIR for the TXD though it worked. :D

mago

Microbit wrote:
Good luck with your code ....
One day a customer will be using (old stock) F149 instead and it'll be :
"Gosh, the serial just stopped working, we just can't figure out why...".

Two days of frantic debugging later it'll sound like this :
"Oops, I thought that the P3DIR register didn't need setting its bits for the TXD pin(s)..."

And all for the sake of 1 line of ASM or C...
Well, I guess we'll never know now :-)

Best Regards,
Kris
-----Original Message-----
From: m... [mailto:m...] On Behalf Of David Collier
Sent: Wednesday, 7 March 2007 10:13 PM
To: m...
Subject: RE: [msp430] UART Response Problem

Hmmmm

I thought that for the UART pins selecting them as special specifically
DID set the IO direction.... in the 169/1611 anyway.

see pin logic diagram on page 53 of msp430f1611.pdf

David

Yahoo! Groups Links

---------------------------------
Need Mail bonding?
Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users.
Reply by thapeez March 7, 20072007-03-07
I realized I was contradicting myself after I posted. I have no
explanation actually, other than I just forgot to change it.

--- In m..., "old_cow_yellow"
wrote:
>
> Just wonder why you change ME1 with "=0xC0;" but change IE1
> with "|=URXIE0;"?
>
> --- In m..., "thapeez" wrote:
> >
> > Uh, he was responding to me.
> >
> > To the OP: I prefer to manually set the control registers to ensure
> > they're set correctly (i.e. the code below). I can't remember what
> > the U0CTL register is set to initially, but perhaps you're missing a
> > SWRST toggle.
> >
> > U0CTL = 0x01;
> > UCTL0 = 0x11;
> > U0TCTL = 0x30;
> > U0BR0 = 0xD2; // 4.032Mhz/19200 = D2h
> > U0BR1 = 0x00;
> > U0MCTL = 0x00;
> > ME1 = 0xC0;
> > U0CTL = 0x10;
> > IE1 |= URXIE0;
> >
> > Adjust for a different crystal frequency/baud rate.
>
Reply by old_cow_yellow March 7, 20072007-03-07
Just wonder why you change ME1 with "=0xC0;" but change IE1
with "|=URXIE0;"?

--- In m..., "thapeez" wrote:
>
> Uh, he was responding to me.
>
> To the OP: I prefer to manually set the control registers to ensure
> they're set correctly (i.e. the code below). I can't remember what
> the U0CTL register is set to initially, but perhaps you're missing a
> SWRST toggle.
>
> U0CTL = 0x01;
> UCTL0 = 0x11;
> U0TCTL = 0x30;
> U0BR0 = 0xD2; // 4.032Mhz/19200 = D2h
> U0BR1 = 0x00;
> U0MCTL = 0x00;
> ME1 = 0xC0;
> U0CTL = 0x10;
> IE1 |= URXIE0;
>
> Adjust for a different crystal frequency/baud rate.
>