Hi I am evaluating the MSP430 for a new design. To get started, I'm trying to put up a simple link between the micro and the computer using the code below. THis is a 1200 baud link using the supplied 32K crystal. Needless to say I do not see any of the 0xaa characters on the PC terminal. (i have an rs232 transceiver max2232 between the micro and the computer uart). This transceiver works, so that is not the problem! When I put a osc' probe on P3.4, I see an extremly low-level signal around 200mv, I was expecing a nice 0-3V output. This must mean that I'm not setting up the pins correctly. Please advice as to what I am doing wrong. Thanks, Owais CODE: #include <msp430x14x.h> void main(void) { WDTCTL = WDTPW + WDTHOLD; //turn watchdog off UCTL0 = CHAR; //char = 8 bits UTCTL0 = SSEL0; //uclk = aclk (from 32.768 crystal); use auxiliary clock source //N = brclk/baudrate = 32.768K/1200 = 27.31 // UBR00 = 0x1B; //lsb(N) of baud rate register UBR00 = 0x03; //lsb(N) of baud rate register UBR10 = 0x00; //msb(N) of baud rate register UMCTL0 = 0x4A;//set modulation cntl register ME1 |= UTXE0 + URXE0; //enable transmit and receive modules for USART0 P3SEL |= 0x30; //P3.4 P3.5, use alternate (UART) function P3DIR |= 0x10; //P3.4 = output direction 00010000 P3DIR &= ~0x20; // set bit 5 to low = input P3DIR |= 0x01; //P3.1 toggle bit (output direction) for(;;) { TXBUF0 = 0xAA; //send again... while(!(UTCTL0 & TXEPT)); P3OUT ^= 0x01; // P1OUT ^= 0x01; // Toggle P1.0 using exclusive-OR } }
Having problems with UART P3.4 (UTXD0) on MSP430F149
Started by ●March 13, 2006
Reply by ●March 14, 20062006-03-14
Take a moment to read page 13-4 of the user's guide (SLAU049). There is
a correct sequence to initialize UART described over there.
Regards,
Adriano.
owaiscareer wrote:
> Hi
>
> I am evaluating the MSP430 for a new design. To get started, I'm
> trying to put up a simple link between the micro and the computer
> using the code below. THis is a 1200 baud link using the supplied 32K
> crystal. Needless to say I do not see any of the 0xaa characters on
> the PC terminal. (i have an rs232 transceiver max2232 between the
> micro and the computer uart). This transceiver works, so that is not
> the problem! When I put a osc' probe on P3.4, I see an extremly
> low-level signal around 200mv, I was expecing a nice 0-3V output.
> This must mean that I'm not setting up the pins correctly. Please
> advice as to what I am doing wrong.
> Thanks,
> Owais
>
> CODE:
>
>
> #include <msp430x14x.h>
>
> void main(void)
> {
> WDTCTL = WDTPW + WDTHOLD; //turn watchdog off
>
> UCTL0 = CHAR; //char = 8 bits
> UTCTL0 = SSEL0; //uclk = aclk (from 32.768 crystal); use auxiliary
> clock source
>
> //N = brclk/baudrate = 32.768K/1200 = 27.31
> // UBR00 = 0x1B; //lsb(N) of baud rate register
> UBR00 = 0x03; //lsb(N) of baud rate register
> UBR10 = 0x00; //msb(N) of baud rate register
> UMCTL0 = 0x4A;//set modulation cntl register
>
> ME1 |= UTXE0 + URXE0; //enable transmit and receive modules for USART0
> P3SEL |= 0x30; //P3.4 P3.5, use alternate (UART) function
> P3DIR |= 0x10; //P3.4 = output direction 00010000
> P3DIR &= ~0x20; // set bit 5 to low = input
> P3DIR |= 0x01; //P3.1 toggle bit (output direction)
> for(;;)
> {
> TXBUF0 = 0xAA; //send again...
> while(!(UTCTL0 & TXEPT));
> P3OUT ^= 0x01;
> // P1OUT ^= 0x01; // Toggle P1.0 using
> exclusive-OR
> }
> }
>
>
>
>
>
>
>
> .
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
Reply by ●March 14, 20062006-03-14
Hi Adriano, I looked and implemented with no progress on UART0: please see below (I now disable the UART state machine before initializing the registers: UCTL0 |= SWRST) ...curiously, moving the same code to UART1 makes it spit out data but it is the wrong baud rate (250Khz) when I measure with the oscilloscope, the data line is correctly toggling between 0 and 3.3V though. What gives? Thanks, Owais void main(void) { WDTCTL = WDTPW + WDTHOLD; //turn watchdog off UCTL0 |= SWRST; UCTL0 |= CHAR; //char = 8 bits UTCTL0 |= SSEL0; //uclk = aclk (from 32.768 crystal); use auxiliary clock source //N = brclk/baudrate = 32.768K/1200 = 27.31 // UBR00 = 0x1B; //lsb(N) of baud rate register UBR00 = 0x03; //lsb(N) of baud rate register UBR10 = 0x00; //msb(N) of baud rate register UMCTL0 = 0x4A;//set modulation cntl register ME1 |= UTXE0 + URXE0; //enable transmit and receive modules for USART0 UCTL0 &= ~SWRST; // Initialize USART state machine P3SEL |= 0x30; //P3.4 P3.5, use alternate (UART) function 11000000 P3DIR |= 0x10; //P3.4 = output direction 01000000 P3DIR &= ~0x20; // set bit 5 to low = input 1000000 P3DIR |= 0x01; //P3.1 toggle bit (output direction) for(;;) { TXBUF0 = 0xAA; //send again... while(!(UTCTL0 & TXEPT)); P3OUT ^= 0x01; // P1OUT ^= 0x01; // Toggle P1.0 using exclusive-OR } } --- In msp430@msp4..., Adriano Caye <adriano@...> wrote: > > > Take a moment to read page 13-4 of the user's guide (SLAU049). There is > a correct sequence to initialize UART described over there. > > Regards, > Adriano. > > owaiscareer wrote: > > Hi > > > > I am evaluating the MSP430 for a new design. To get started, I'm > > trying to put up a simple link between the micro and the computer > > using the code below. THis is a 1200 baud link using the supplied 32K > > crystal. Needless to say I do not see any of the 0xaa characters on > > the PC terminal. (i have an rs232 transceiver max2232 between the > > micro and the computer uart). This transceiver works, so that is not > > the problem! When I put a osc' probe on P3.4, I see an extremly > > low-level signal around 200mv, I was expecing a nice 0-3V output. > > This must mean that I'm not setting up the pins correctly. Please > > advice as to what I am doing wrong. > > Thanks, > > Owais > > > > CODE: > > > > > > #include <msp430x14x.h> > > > > void main(void) > > { > > WDTCTL = WDTPW + WDTHOLD; //turn watchdog off > > > > UCTL0 = CHAR; //char = 8 bits > > UTCTL0 = SSEL0; //uclk = aclk (from 32.768 crystal); use auxiliary > > clock source > > > > //N = brclk/baudrate = 32.768K/1200 = 27.31 > > // UBR00 = 0x1B; //lsb(N) of baud rate register > > UBR00 = 0x03; //lsb(N) of baud rate register > > UBR10 = 0x00; //msb(N) of baud rate register > > UMCTL0 = 0x4A;//set modulation cntl register > > > > ME1 |= UTXE0 + URXE0; //enable transmit and receive modules for USART0 > > P3SEL |= 0x30; //P3.4 P3.5, use alternate (UART) function > > P3DIR |= 0x10; //P3.4 = output direction 00010000 > > P3DIR &= ~0x20; // set bit 5 to low = input > > P3DIR |= 0x01; //P3.1 toggle bit (output direction) > > for(;;) > > { > > TXBUF0 = 0xAA; //send again... > > while(!(UTCTL0 & TXEPT)); > > P3OUT ^= 0x01; > > // P1OUT ^= 0x01; // Toggle P1.0 using > > exclusive-OR > > } > > } > > > > > > > > > > > > > > > > . > > > > > > Yahoo! Groups Links > > > > > > > > > > > > > > >
Reply by ●March 14, 20062006-03-14
owaiscareer wrote:
> Hi Adriano,
>
> I looked and implemented with no progress on UART0: please see below
> (I now disable the UART state machine before initializing the
> registers: UCTL0 |= SWRST)
>
> ...curiously, moving the same code to UART1 makes it spit out data but
> it is the wrong baud rate (250Khz) when I measure with the
> oscilloscope, the data line is correctly toggling between 0 and 3.3V
> though. What gives?
>
> Thanks,
> Owais
>
> void main(void)
> {
> WDTCTL = WDTPW + WDTHOLD; //turn watchdog off
>
> UCTL0 |= SWRST;
>
> UCTL0 |= CHAR; //char = 8 bits
> UTCTL0 |= SSEL0; //uclk = aclk (from 32.768 crystal); use auxiliary
> clock source
>
> //N = brclk/baudrate = 32.768K/1200 = 27.31
> // UBR00 = 0x1B; //lsb(N) of baud rate register
> UBR00 = 0x03; //lsb(N) of baud rate register
> UBR10 = 0x00; //msb(N) of baud rate register
> UMCTL0 = 0x4A;//set modulation cntl register
>
>
> ME1 |= UTXE0 + URXE0; //enable transmit and receive modules for USART0
>
> UCTL0 &= ~SWRST; // Initialize USART state
> machine
>
> P3SEL |= 0x30; //P3.4 P3.5, use alternate (UART) function 11000000
> P3DIR |= 0x10; //P3.4 = output direction 01000000
> P3DIR &= ~0x20; // set bit 5 to low = input 1000000
> P3DIR |= 0x01; //P3.1 toggle bit (output direction)
> for(;;)
> {
> TXBUF0 = 0xAA; //send again...
> while(!(UTCTL0 & TXEPT));
> P3OUT ^= 0x01;
> // P1OUT ^= 0x01; // Toggle P1.0 using
> exclusive-OR
> }
> }
It looks like you have it set up correctly. I do notice that it looks
like you're trying to run at 9600 baud, based on the values of UBR00 and
UBR10. That being the case, the 250 KHz output you are getting sounds
like you are running off of the default DCO frequency of approximately
750 KHz. Take a look to make sure that the ACLK is selected in UTCTL0
and not the SMCLK.
HTH,
Greg
Reply by ●March 14, 20062006-03-14
Thanks! since uart0 did not work, i switched to uart1, by changing all 0s to 1s, i changed ssel0 to ssel1 mistakenly. And yes, I did notice the wrong baud rate in the meantime...TI tech support also got back to me, the other problem was I was using a really old version of IAR kickstart. Both these changes when applied worked! Thanks to everyone that helped! --- In msp430@msp4..., Greg Maki <gmaki@...> wrote: > > owaiscareer wrote: > > Hi Adriano, > > > > I looked and implemented with no progress on UART0: please see below > > (I now disable the UART state machine before initializing the > > registers: UCTL0 |= SWRST) > > > > ...curiously, moving the same code to UART1 makes it spit out data but > > it is the wrong baud rate (250Khz) when I measure with the > > oscilloscope, the data line is correctly toggling between 0 and 3.3V > > though. What gives? > > > > Thanks, > > Owais > > > > void main(void) > > { > > WDTCTL = WDTPW + WDTHOLD; //turn watchdog off > > > > UCTL0 |= SWRST; > > > > UCTL0 |= CHAR; //char = 8 bits > > UTCTL0 |= SSEL0; //uclk = aclk (from 32.768 crystal); use auxiliary > > clock source > > > > //N = brclk/baudrate = 32.768K/1200 = 27.31 > > // UBR00 = 0x1B; //lsb(N) of baud rate register > > UBR00 = 0x03; //lsb(N) of baud rate register > > UBR10 = 0x00; //msb(N) of baud rate register > > UMCTL0 = 0x4A;//set modulation cntl register > > > > > > ME1 |= UTXE0 + URXE0; //enable transmit and receive modules for USART0 > > > > UCTL0 &= ~SWRST; // Initialize USART state > > machine > > > > P3SEL |= 0x30; //P3.4 P3.5, use alternate (UART) function 11000000 > > P3DIR |= 0x10; //P3.4 = output direction 01000000 > > P3DIR &= ~0x20; // set bit 5 to low = input 1000000 > > P3DIR |= 0x01; //P3.1 toggle bit (output direction) > > for(;;) > > { > > TXBUF0 = 0xAA; //send again... > > while(!(UTCTL0 & TXEPT)); > > P3OUT ^= 0x01; > > // P1OUT ^= 0x01; // Toggle P1.0 using > > exclusive-OR > > } > > } > > It looks like you have it set up correctly. I do notice that it looks > like you're trying to run at 9600 baud, based on the values of UBR00 and > UBR10. That being the case, the 250 KHz output you are getting sounds > like you are running off of the default DCO frequency of approximately > 750 KHz. Take a look to make sure that the ACLK is selected in UTCTL0 > and not the SMCLK. > > HTH, > > Greg >