EmbeddedRelated.com
Forums

communication between two msp430 devices sing uart

Started by pari...@gmail.com February 11, 2009
hi everybody

i have tedious problem with two msp430fg439 device .My purpose is achieving cummunication between them using their usart module in uart mode
by the way this microntrollers are in their development board, that is i did not work out any pcb for them. Any way...
i m using cce v3.2 core edition
i simple connected the tx to rx and rx to tx between two micro.
i write firstly any charater to the txbuf.ok then. i see that character is prooerly written there. But as to other characters(2. 3. etc) they can not be written in other words transmitter always seems bussy(interrrupt flag always 0)

(incidentelly do i have to tie thegrounds in pin number 78 and 79 with the same pins of the second micro??)

first quenstion is here .first of all do ı have to send the address of the receiverbuffer.(rxbuf)??facilatitng some manupulations on TXwake ??

secondly in my point of view receiver never gets any character because is flag always stays in 0.

i used identical modulation and baud rate setting for both receiver and transitter micro.

Any help will be greatly appreciated and thanks to all helpers

CODES:
************************code for slave*******************
#include
int count=0;char ch[]={'m',0X76,7};
void setclk();
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
setclk();

P2SEL |= 0x30; // P2.4,5 = USART0 TXD/RXD
ME1 |= UTXE0 + URXE0; // Enable USART0 TXD/RXD
UCTL0 |= CHAR; // 8-bit character
UTCTL0 |= SSEL1+TXWAKE; // UCLK = SMCLK
UBR00 = 0x6D; // 1MHz 9600
UBR10 = 0x00; //
UMCTL0 = 0x03; // Modulation
UCTL0 &= ~SWRST; // Initialize USART state machine
IE1 |= UTXIE0; // Enable USART0 RX interrupt
P2DIR |= 0x10; // P2.4 output direction

_EINT();
while(1){ }
}

#pragma vector=USART0TX_VECTOR
__interrupt void usart0_tx (void)
{
//while (!(IFG1 & UTXIFG0));
if(count<3)
{ TXBUF0 =ch[count++]; }
P1SEL=0X02;P1DIR=0X02;
}

void setclk()
{
SCFQCTL1;
SCFI0|=FLLD_2;

FLL_CTL0 =0X30;

//while ( LFOF & FLL_CTL0); // wait for watch crystal to stabilize

for (int i = 0; i < 10000; i++); // Delay for 32 kHz crystal to
// stabilize
do
{
IFG1=0X02;
IFG1 &= ~OFIFG; // Clear osc fault flag
for (int i = 0; i < 1000; i++); // Delay for osc to stabilize
} while(IFG1 & OFIFG); // Check to see if osc flag is set

FLL_CTL1=0X60;
}

code for master*******************************************
#include
int count=0;char ch[]={'m',0X76,7};
void setclk();
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
setclk();

P2SEL |= 0x30; // P2.4,5 = USART0 TXD/RXD
ME1 |= UTXE0 + URXE0; // Enable USART0 TXD/RXD
UCTL0 |= CHAR; // 8-bit character
UTCTL0 |= SSEL1+TXWAKE; // UCLK = SMCLK
UBR00 = 0x6D; // 1MHz 9600
UBR10 = 0x00; //
UMCTL0 = 0x03; // Modulation
UCTL0 &= ~SWRST; // Initialize USART state machine
IE1 |= UTXIE0; // Enable USART0 RX interrupt
P2DIR |= 0x10; // P2.4 output direction

_EINT();
while(1){ }
}

#pragma vector=USART0TX_VECTOR
__interrupt void usart0_tx (void)
{
//while (!(IFG1 & UTXIFG0));
if(count<3)
{ TXBUF0 =ch[count++]; }
P1SEL=0X02;P1DIR=0X02;
}

void setclk()
{
SCFQCTL1;
SCFI0|=FLLD_2;

FLL_CTL0 =0X30;

//while ( LFOF & FLL_CTL0); // wait for watch crystal to stabilize

for (int i = 0; i < 10000; i++); // Delay for 32 kHz crystal to
// stabilize
do
{
IFG1=0X02;
IFG1 &= ~OFIFG; // Clear osc fault flag
for (int i = 0; i < 1000; i++); // Delay for osc to stabilize
} while(IFG1 & OFIFG); // Check to see if osc flag is set

FLL_CTL1=0X60;
}

Beginning Microcontrollers with the MSP430

Hello,

This is a stupid question, but nevertheless, did you cross the Rx and Tx
lines?

Larry

-----Original Message-----
From: m... [mailto:m...] On Behalf Of
p...@gmail.com
Sent: Wednesday, February 11, 2009 6:19 AM
To: m...
Subject: [msp430] communication between two msp430 devices sing uart

hi everybody

i have tedious problem with two msp430fg439 device .My purpose is achieving
cummunication between them using their usart module in uart mode by the way
this microntrollers are in their development board, that is i did not work
out any pcb for them. Any way...
i m using cce v3.2 core edition
i simple connected the tx to rx and rx to tx between two micro.
i write firstly any charater to the txbuf.ok then. i see that character is
prooerly written there. But as to other characters(2. 3. etc) they can not
be written in other words transmitter always seems bussy(interrrupt flag
always 0)

(incidentelly do i have to tie thegrounds in pin number 78 and 79 with the
same pins of the second micro??)

first quenstion is here .first of all do ı have to send the address of the
receiverbuffer.(rxbuf)??facilatitng some manupulations on TXwake ??

secondly in my point of view receiver never gets any character because is
flag always stays in 0.

i used identical modulation and baud rate setting for both receiver and
transitter micro.

Any help will be greatly appreciated and thanks to all helpers

CODES:
************************code for slave******************* #include
int count=0;char ch[]={'m',0X76,7}; void setclk(); void
main(void) {
WDTCTL = WDTPW + WDTHOLD;
setclk();

P2SEL |= 0x30; // P2.4,5 = USART0 TXD/RXD
ME1 |= UTXE0 + URXE0; // Enable USART0 TXD/RXD
UCTL0 |= CHAR; // 8-bit character
UTCTL0 |= SSEL1+TXWAKE; // UCLK = SMCLK
UBR00 = 0x6D; // 1MHz 9600
UBR10 = 0x00; //
UMCTL0 = 0x03; // Modulation
UCTL0 &= ~SWRST; // Initialize USART state
machine
IE1 |= UTXIE0; // Enable USART0 RX interrupt
P2DIR |= 0x10; // P2.4 output direction

_EINT();
while(1){ }
}

#pragma vector=USART0TX_VECTOR
__interrupt void usart0_tx (void)
{
//while (!(IFG1 & UTXIFG0));
if(count<3)
{ TXBUF0 =ch[count++]; }
P1SEL=0X02;P1DIR=0X02;
}

void setclk()
{
SCFQCTL=31;
SCFI0|=FLLD_2;

FLL_CTL0 =0X30;

//while ( LFOF & FLL_CTL0); // wait for watch crystal to
stabilize

for (int i = 0; i < 10000; i++); // Delay for 32 kHz crystal
to
// stabilize
do
{
IFG1=0X02;
IFG1 &= ~OFIFG; // Clear osc fault flag
for (int i = 0; i < 1000; i++); // Delay for osc to
stabilize
} while(IFG1 & OFIFG); // Check to see if osc flag is
set

FLL_CTL1=0X60;
}

code for master*******************************************
#include
int count=0;char ch[]={'m',0X76,7};
void setclk();
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
setclk();

P2SEL |= 0x30; // P2.4,5 = USART0 TXD/RXD
ME1 |= UTXE0 + URXE0; // Enable USART0 TXD/RXD
UCTL0 |= CHAR; // 8-bit character
UTCTL0 |= SSEL1+TXWAKE; // UCLK = SMCLK
UBR00 = 0x6D; // 1MHz 9600
UBR10 = 0x00; //
UMCTL0 = 0x03; // Modulation
UCTL0 &= ~SWRST; // Initialize USART state
machine
IE1 |= UTXIE0; // Enable USART0 RX interrupt
P2DIR |= 0x10; // P2.4 output direction

_EINT();
while(1){ }
}

#pragma vector=USART0TX_VECTOR
__interrupt void usart0_tx (void)
{
//while (!(IFG1 & UTXIFG0));
if(count<3)
{ TXBUF0 =ch[count++]; }
P1SEL=0X02;P1DIR=0X02;
}

void setclk()
{
SCFQCTL=31;
SCFI0|=FLLD_2;

FLL_CTL0 =0X30;

//while ( LFOF & FLL_CTL0); // wait for watch crystal to
stabilize

for (int i = 0; i < 10000; i++); // Delay for 32 kHz crystal
to
// stabilize
do
{
IFG1=0X02;
IFG1 &= ~OFIFG; // Clear osc fault flag
for (int i = 0; i < 1000; i++); // Delay for osc to
stabilize
} while(IFG1 & OFIFG); // Check to see if osc flag is
set

FLL_CTL1=0X60;
}

Hi

> (incidentelly do i have to tie thegrounds in pin number 78 and 79
> with the same pins of the second micro??)
UART needs at least 3 signals for bidirectional communication: Tx, Rx
and GND. Remember, voltage is a difference of electrical potential, so
it is always with respect to something else ('else' being usually GND).

> i write firstly any charater to the txbuf.ok then. i see that
> character is prooerly written there. But as to other characters(2.
> 3. etc) they can not be written in other words transmitter always
> seems bussy(interrrupt flag always 0)
That's strange. You should be able to write at least two bytes (one in
the shift register, the other in the buffer) before the buffer
indicates it's full. This would mean that the clock feeding the UART
isn't working. Check the SMCLK configuration.

Michael K.
--- In m..., pariawe@... wrote:
>
> hi everybody
>
> i have tedious problem with two msp430fg439 device .My purpose is
achieving cummunication between them using their usart module in uart mode
> by the way this microntrollers are in their development board, that
is i did not work out any pcb for them. Any way...
> i m using cce v3.2 core edition
> i simple connected the tx to rx and rx to tx between two micro.
> i write firstly any charater to the txbuf.ok then. i see that
character is prooerly written there. But as to other characters(2. 3.
etc) they can not be written in other words transmitter always seems
bussy(interrrupt flag always 0)
>
> (incidentelly do i have to tie thegrounds in pin number 78 and 79
with the same pins of the second micro??)
>
> first quenstion is here .first of all do ı have to send the address
of the receiverbuffer.(rxbuf)??facilatitng some manupulations on TXwake ??
>
> secondly in my point of view receiver never gets any character
because is flag always stays in 0.
>
> i used identical modulation and baud rate setting for both receiver
and transitter micro.
>
> Any help will be greatly appreciated and thanks to all helpers
>
> CODES:
> ************************code for slave*******************
> #include
> int count=0;char ch[]={'m',0X76,7};
> void setclk();
> void main(void)
> {
> WDTCTL = WDTPW + WDTHOLD;
> setclk();
>
> P2SEL |= 0x30; // P2.4,5 = USART0 TXD/RXD
> ME1 |= UTXE0 + URXE0; // Enable USART0 TXD/RXD
> UCTL0 |= CHAR; // 8-bit character
> UTCTL0 |= SSEL1+TXWAKE; // UCLK = SMCLK
> UBR00 = 0x6D; // 1MHz 9600
> UBR10 = 0x00; //
> UMCTL0 = 0x03; // Modulation
> UCTL0 &= ~SWRST; // Initialize USART
state machine
> IE1 |= UTXIE0; // Enable USART0 RX
interrupt
> P2DIR |= 0x10; // P2.4 output direction
>
> _EINT();
> while(1){ }
> }
>
> #pragma vector=USART0TX_VECTOR
> __interrupt void usart0_tx (void)
> {
> //while (!(IFG1 & UTXIFG0));
> if(count<3)
> { TXBUF0 =ch[count++]; }
> P1SEL=0X02;P1DIR=0X02;
> }
>
> void setclk()
> {
> SCFQCTL=31;
> SCFI0|=FLLD_2;
>
> FLL_CTL0 =0X30;
>
> //while ( LFOF & FLL_CTL0); // wait for watch
crystal to stabilize
>
> for (int i = 0; i < 10000; i++); // Delay for 32 kHz
crystal to
> // stabilize
> do
> {
> IFG1=0X02;
> IFG1 &= ~OFIFG; // Clear osc fault flag
> for (int i = 0; i < 1000; i++); // Delay for osc to
stabilize
> } while(IFG1 & OFIFG); // Check to see if osc
flag is set
>
> FLL_CTL1=0X60;
> }
>
> code for master*******************************************
>
>
> #include
> int count=0;char ch[]={'m',0X76,7};
> void setclk();
> void main(void)
> {
> WDTCTL = WDTPW + WDTHOLD;
> setclk();
>
> P2SEL |= 0x30; // P2.4,5 = USART0 TXD/RXD
> ME1 |= UTXE0 + URXE0; // Enable USART0 TXD/RXD
> UCTL0 |= CHAR; // 8-bit character
> UTCTL0 |= SSEL1+TXWAKE; // UCLK = SMCLK
> UBR00 = 0x6D; // 1MHz 9600
> UBR10 = 0x00; //
> UMCTL0 = 0x03; // Modulation
> UCTL0 &= ~SWRST; // Initialize USART
state machine
> IE1 |= UTXIE0; // Enable USART0 RX
interrupt
> P2DIR |= 0x10; // P2.4 output direction
>
> _EINT();
> while(1){ }
> }
>
> #pragma vector=USART0TX_VECTOR
> __interrupt void usart0_tx (void)
> {
> //while (!(IFG1 & UTXIFG0));
> if(count<3)
> { TXBUF0 =ch[count++]; }
> P1SEL=0X02;P1DIR=0X02;
> }
>
> void setclk()
> {
> SCFQCTL=31;
> SCFI0|=FLLD_2;
>
> FLL_CTL0 =0X30;
>
> //while ( LFOF & FLL_CTL0); // wait for watch
crystal to stabilize
>
> for (int i = 0; i < 10000; i++); // Delay for 32 kHz
crystal to
> // stabilize
> do
> {
> IFG1=0X02;
> IFG1 &= ~OFIFG; // Clear osc fault flag
> for (int i = 0; i < 1000; i++); // Delay for osc to
stabilize
> } while(IFG1 & OFIFG); // Check to see if osc
flag is set
>
> FLL_CTL1=0X60;
> }
>

A couple of things to check on :

The master and slave code both list the same line :
> IE1 |= UTXIE0; // Enable USART0 RX interrupt
I presume your slave needs RX enabled, not TX at this stage.
But TX is not working on Master, that's the first thing. It sounds like you
don;t ahve a clock to the USART.
I'm not to sure about that TXWAKE business. Check your SWRST sequence, I
don't see it being set.
Also, you need to "kick" TX for interrupts to start. The first transmission
needs to be a write to TX buffer, then your TX empty/ready interrupts will
start. Your Master code just sits in a while{} loop, it's not starting off
the TX. Once started then your ISR will send the 3 chars in ch[].

HTH
Kris
> --- In m..., pariawe@... wrote:
>>
>> hi everybody
>>
>> i have tedious problem with two msp430fg439 device .My purpose is
> achieving cummunication between them using their usart module in uart
mode
>> by the way this microntrollers are in their development board, that
> is i did not work out any pcb for them. Any way...
>> i m using cce v3.2 core edition
>> i simple connected the tx to rx and rx to tx between two micro.
>> i write firstly any charater to the txbuf.ok then. i see that
> character is prooerly written there. But as to other characters(2. 3.
> etc) they can not be written in other words transmitter always seems
> bussy(interrrupt flag always 0)
>>
>> (incidentelly do i have to tie thegrounds in pin number 78 and 79
> with the same pins of the second micro??)
>>
>> first quenstion is here .first of all do ı have to send the address
> of the receiverbuffer.(rxbuf)??facilatitng some manupulations on TXwake
??
>>
>> secondly in my point of view receiver never gets any character
> because is flag always stays in 0.
>>
>> i used identical modulation and baud rate setting for both receiver
> and transitter micro.
>>
>> Any help will be greatly appreciated and thanks to all helpers
>>
>> CODES:
>> ************************code for slave*******************
>> #include
>> int count=0;char ch[]={'m',0X76,7};
>> void setclk();
>> void main(void)
>> {
>> WDTCTL = WDTPW + WDTHOLD;
>> setclk();
>>
>> P2SEL |= 0x30; // P2.4,5 = USART0 TXD/RXD
>> ME1 |= UTXE0 + URXE0; // Enable USART0 TXD/RXD
>> UCTL0 |= CHAR; // 8-bit character
>> UTCTL0 |= SSEL1+TXWAKE; // UCLK = SMCLK
>> UBR00 = 0x6D; // 1MHz 9600
>> UBR10 = 0x00; //
>> UMCTL0 = 0x03; // Modulation
>> UCTL0 &= ~SWRST; // Initialize USART
> state machine
>> IE1 |= UTXIE0; // Enable USART0 RX
> interrupt
>> P2DIR |= 0x10; // P2.4 output direction
>>
>> _EINT();
>> while(1){ }
>> }
>>
>> #pragma vector=USART0TX_VECTOR
>> __interrupt void usart0_tx (void)
>> {
>> //while (!(IFG1 & UTXIFG0));
>> if(count<3)
>> { TXBUF0 =ch[count++]; }
>> P1SEL=0X02;P1DIR=0X02;
>> }
>>
>> void setclk()
>> {
>> SCFQCTL1;
>> SCFI0|=FLLD_2;
>>
>> FLL_CTL0 =0X30;
>>
>> //while ( LFOF & FLL_CTL0); // wait for watch
> crystal to stabilize
>>
>> for (int i = 0; i < 10000; i++); // Delay for 32 kHz
> crystal to
>> // stabilize
>> do
>> {
>> IFG1=0X02;
>> IFG1 &= ~OFIFG; // Clear osc fault flag
>> for (int i = 0; i < 1000; i++); // Delay for osc to
> stabilize
>> } while(IFG1 & OFIFG); // Check to see if osc
> flag is set
>>
>> FLL_CTL1=0X60;
>> }
>>
>> code for master*******************************************
>> #include
>> int count=0;char ch[]={'m',0X76,7};
>> void setclk();
>> void main(void)
>> {
>> WDTCTL = WDTPW + WDTHOLD;
>> setclk();
>>
>> P2SEL |= 0x30; // P2.4,5 = USART0 TXD/RXD
>> ME1 |= UTXE0 + URXE0; // Enable USART0 TXD/RXD
>> UCTL0 |= CHAR; // 8-bit character
>> UTCTL0 |= SSEL1+TXWAKE; // UCLK = SMCLK
>> UBR00 = 0x6D; // 1MHz 9600
>> UBR10 = 0x00; //
>> UMCTL0 = 0x03; // Modulation
>> UCTL0 &= ~SWRST; // Initialize USART
> state machine
>> IE1 |= UTXIE0; // Enable USART0 RX
> interrupt
>> P2DIR |= 0x10; // P2.4 output direction
>>
>> _EINT();
>> while(1){ }
>> }
>>
>> #pragma vector=USART0TX_VECTOR
>> __interrupt void usart0_tx (void)
>> {
>> //while (!(IFG1 & UTXIFG0));
>> if(count<3)
>> { TXBUF0 =ch[count++]; }
>> P1SEL=0X02;P1DIR=0X02;
>> }
>>
>> void setclk()
>> {
>> SCFQCTL1;
>> SCFI0|=FLLD_2;
>>
>> FLL_CTL0 =0X30;
>>
>> //while ( LFOF & FLL_CTL0); // wait for watch
> crystal to stabilize
>>
>> for (int i = 0; i < 10000; i++); // Delay for 32 kHz
> crystal to
>> // stabilize
>> do
>> {
>> IFG1=0X02;
>> IFG1 &= ~OFIFG; // Clear osc fault flag
>> for (int i = 0; i < 1000; i++); // Delay for osc to
> stabilize
>> } while(IFG1 & OFIFG); // Check to see if osc
> flag is set
>>
>> FLL_CTL1=0X60;
>> }
>>

Hi Microbit,

> Also, you need to "kick" TX for interrupts to start. The first
> transmission needs to be a write to TX buffer, then your TX
> empty/ready interrupts will start.
Are you sure? UTXIFG is set whenever TXBUF is empty, even after POR,
which means that as soon as UTXIE and GIE are set, an interrupt will
be trigged.

Michael

--- In m..., wrote:
>
> A couple of things to check on :
>
> The master and slave code both list the same line :
> > IE1 |= UTXIE0; // Enable USART0 RX
interrupt
> I presume your slave needs RX enabled, not TX at this stage.
> But TX is not working on Master, that's the first thing. It sounds
like you
> don;t ahve a clock to the USART.
> I'm not to sure about that TXWAKE business. Check your SWRST sequence, I
> don't see it being set.
> Also, you need to "kick" TX for interrupts to start. The first
transmission
> needs to be a write to TX buffer, then your TX empty/ready
interrupts will
> start. Your Master code just sits in a while{} loop, it's not
starting off
> the TX. Once started then your ISR will send the 3 chars in ch[].
>
> HTH
> Kris
>
>
> > --- In m..., pariawe@ wrote:
> >>
> >> hi everybody
> >>
> >> i have tedious problem with two msp430fg439 device .My purpose is
> > achieving cummunication between them using their usart module in uart
> mode
> >> by the way this microntrollers are in their development board, that
> > is i did not work out any pcb for them. Any way...
> >> i m using cce v3.2 core edition
> >> i simple connected the tx to rx and rx to tx between two micro.
> >> i write firstly any charater to the txbuf.ok then. i see that
> > character is prooerly written there. But as to other characters(2. 3.
> > etc) they can not be written in other words transmitter always seems
> > bussy(interrrupt flag always 0)
> >>
> >> (incidentelly do i have to tie thegrounds in pin number 78 and 79
> > with the same pins of the second micro??)
> >>
> >> first quenstion is here .first of all do #65533;± have to send the
address
> > of the receiverbuffer.(rxbuf)??facilatitng some manupulations on
TXwake
> ??
> >>
> >> secondly in my point of view receiver never gets any character
> > because is flag always stays in 0.
> >>
> >> i used identical modulation and baud rate setting for both receiver
> > and transitter micro.
> >>
> >> Any help will be greatly appreciated and thanks to all helpers
> >>
> >> CODES:
> >> ************************code for slave*******************
> >> #include
> >> int count=0;char ch[]={'m',0X76,7};
> >> void setclk();
> >> void main(void)
> >> {
> >> WDTCTL = WDTPW + WDTHOLD;
> >> setclk();
> >>
> >> P2SEL |= 0x30; // P2.4,5 = USART0
TXD/RXD
> >> ME1 |= UTXE0 + URXE0; // Enable USART0 TXD/RXD
> >> UCTL0 |= CHAR; // 8-bit character
> >> UTCTL0 |= SSEL1+TXWAKE; // UCLK = SMCLK
> >> UBR00 = 0x6D; // 1MHz 9600
> >> UBR10 = 0x00; //
> >> UMCTL0 = 0x03; // Modulation
> >> UCTL0 &= ~SWRST; // Initialize USART
> > state machine
> >> IE1 |= UTXIE0; // Enable USART0 RX
> > interrupt
> >> P2DIR |= 0x10; // P2.4 output direction
> >>
> >> _EINT();
> >> while(1){ }
> >> }
> >>
> >> #pragma vector=USART0TX_VECTOR
> >> __interrupt void usart0_tx (void)
> >> {
> >> //while (!(IFG1 & UTXIFG0));
> >> if(count<3)
> >> { TXBUF0 =ch[count++]; }
> >> P1SEL=0X02;P1DIR=0X02;
> >> }
> >>
> >> void setclk()
> >> {
> >> SCFQCTL=31;
> >> SCFI0|=FLLD_2;
> >>
> >> FLL_CTL0 =0X30;
> >>
> >> //while ( LFOF & FLL_CTL0); // wait for watch
> > crystal to stabilize
> >>
> >> for (int i = 0; i < 10000; i++); // Delay for 32 kHz
> > crystal to
> >> // stabilize
> >> do
> >> {
> >> IFG1=0X02;
> >> IFG1 &= ~OFIFG; // Clear osc fault flag
> >> for (int i = 0; i < 1000; i++); // Delay for osc to
> > stabilize
> >> } while(IFG1 & OFIFG); // Check to see if osc
> > flag is set
> >>
> >> FLL_CTL1=0X60;
> >> }
> >>
> >> code for master*******************************************
> >>
> >>
> >> #include
> >> int count=0;char ch[]={'m',0X76,7};
> >> void setclk();
> >> void main(void)
> >> {
> >> WDTCTL = WDTPW + WDTHOLD;
> >> setclk();
> >>
> >> P2SEL |= 0x30; // P2.4,5 = USART0
TXD/RXD
> >> ME1 |= UTXE0 + URXE0; // Enable USART0 TXD/RXD
> >> UCTL0 |= CHAR; // 8-bit character
> >> UTCTL0 |= SSEL1+TXWAKE; // UCLK = SMCLK
> >> UBR00 = 0x6D; // 1MHz 9600
> >> UBR10 = 0x00; //
> >> UMCTL0 = 0x03; // Modulation
> >> UCTL0 &= ~SWRST; // Initialize USART
> > state machine
> >> IE1 |= UTXIE0; // Enable USART0 RX
> > interrupt
> >> P2DIR |= 0x10; // P2.4 output direction
> >>
> >> _EINT();
> >> while(1){ }
> >> }
> >>
> >> #pragma vector=USART0TX_VECTOR
> >> __interrupt void usart0_tx (void)
> >> {
> >> //while (!(IFG1 & UTXIFG0));
> >> if(count<3)
> >> { TXBUF0 =ch[count++]; }
> >> P1SEL=0X02;P1DIR=0X02;
> >> }
> >>
> >> void setclk()
> >> {
> >> SCFQCTL=31;
> >> SCFI0|=FLLD_2;
> >>
> >> FLL_CTL0 =0X30;
> >>
> >> //while ( LFOF & FLL_CTL0); // wait for watch
> > crystal to stabilize
> >>
> >> for (int i = 0; i < 10000; i++); // Delay for 32 kHz
> > crystal to
> >> // stabilize
> >> do
> >> {
> >> IFG1=0X02;
> >> IFG1 &= ~OFIFG; // Clear osc fault flag
> >> for (int i = 0; i < 1000; i++); // Delay for osc to
> > stabilize
> >> } while(IFG1 & OFIFG); // Check to see if osc
> > flag is set
> >>
> >> FLL_CTL1=0X60;
> >> }
> >

On Wed, 2009-02-11 at 14:04 +0000, tintronic wrote:
> Hi Microbit,
>
> > Also, you need to "kick" TX for interrupts to start. The first
> > transmission needs to be a write to TX buffer, then your TX
> > empty/ready interrupts will start.
> Are you sure? UTXIFG is set whenever TXBUF is empty, even after POR,
> which means that as soon as UTXIE and GIE are set, an interrupt will
> be trigged.
>
> Michael
>

Hi Michael,

It would do that but that's not very practical I thought. Perhaps the
way I stated it might be confusing to the OP.
Normal practice of course is to disable TX interrupts from the TX ISR
when the TX (eg. ring) buffer is empty.
The master code that was given as an example will only send 3 chars once
on startup. I'd want to have it sending eg. every second or some
such :-)

Best regards,
Kris

--- In m..., Microbit_Ubuntu wrote:
>
> On Wed, 2009-02-11 at 14:04 +0000, tintronic wrote:
> > Hi Microbit,
> >
> > > Also, you need to "kick" TX for interrupts to start. The first
> > > transmission needs to be a write to TX buffer, then your TX
> > > empty/ready interrupts will start.
> > Are you sure? UTXIFG is set whenever TXBUF is empty, even after POR,
> > which means that as soon as UTXIE and GIE are set, an interrupt will
> > be trigged.
> >
> > Michael
> >
> >
> > Hi Michael,
>
> It would do that but that's not very practical I thought. Perhaps the
> way I stated it might be confusing to the OP.
> Normal practice of course is to disable TX interrupts from the TX ISR
> when the TX (eg. ring) buffer is empty.
> The master code that was given as an example will only send 3 chars once
> on startup. I'd want to have it sending eg. every second or some
> such :-)
>
> Best regards,
> Kris
>

True, the OPs approach is not good, because after the uart starts
sending the second before last byte, his program will be stuck in the
UART TX interrupt instead of the while(1) in main.

A much better approach would be:

#pragma vector=USART0TX_VECTOR
__interrupt void usart0_tx (void)
{
if(count<3)
TXBUF0 = ch[count++];
else
IE1 &= ~UTXIE0; // Disable USART0 TX interrupt
P1SEL=0X02;P1DIR=0X02;// don't know what this is supposed to do.
}

Michael K.

hi

thank you Kris and Larry and Michael

But Larry i said i crossed the pins as master's TX to slave's RX and vice versa. So that can not be a problem

On the other hand i send codes quite wrongly as you said.i simply paste totlay same codes for master and slave. Bu t be sure the advices of Kris is achieved im codes anyway. But i will connect grounds. i did it but using the connectors which is located at the edge of the pcb. This nd connection is useless because Texas suggest replacing a resistor for rendering this threee connector(two gnd one Vcc)as supplies and reference.

Kris yu said kick Tx but initially its flag is set means it is empty then normally interrupt works transmit buffer is loaded with the first character. But after that other loadings never happens because flag is always zero means transmission is going on . Am i right?
So receiver never accepts any character because its interrupt flag never set.
But we come to a decision as i need only three line as tx(UTXD0) rx(URXD0) and a ground connection not more like external clock connection it is supplied from internally from inside anyway right?(some weird qustions i know but that s a great matter for me, i attempted tremendous drills about uart which gives actually not gives anything)

thank you guys
Hi again.
> But after that other loadings never happens because flag is always
> zero means transmission is going on . Am i right?
Wrong. It means the byte isn't even being transferred out of the shift
register, which means TX is not working, probably because it is not
receiving any clock. Did you check the clock (SMCLK) as we told you? I
didn't see any SMCLK initialization. I don't know what the default
SMCLK source is, but in your hardware configuration it is probably off
after POR.

--- In m..., pariawe@... wrote:
>
> hi
>
> thank you Kris and Larry and Michael
>
> But Larry i said i crossed the pins as master's TX to slave's RX and
vice versa. So that can not be a problem
>
> On the other hand i send codes quite wrongly as you said.i simply
paste totlay same codes for master and slave. Bu t be sure the advices
of Kris is achieved im codes anyway. But i will connect grounds. i did
it but using the connectors which is located at the edge of the pcb.
This nd connection is useless because Texas suggest replacing a
resistor for rendering this threee connector(two gnd one Vcc)as
supplies and reference.
>
> Kris yu said kick Tx but initially its flag is set means it is empty
then normally interrupt works transmit buffer is loaded with the first
character. But after that other loadings never happens because flag is
always zero means transmission is going on . Am i right?
> So receiver never accepts any character because its interrupt flag
never set.
> But we come to a decision as i need only three line as tx(UTXD0)
rx(URXD0) and a ground connection not more like external clock
connection it is supplied from internally from inside anyway
right?(some weird qustions i know but that s a great matter for me, i
attempted tremendous drills about uart which gives actually not gives
anything)
>
> thank you guys
>

Hi friends

Tintronic you are right about the possible cause of the problem
i check SMCLK out so let me proclaim the guilty line

FLL_CTL1=0X60;(located inside the setclk() function)

i simply turn the SMCLK on and finally, happilly, suprisingly saw the trasmition between two micro.

thanks for your advice

but a little snag there

There is code for master micro. transmitter capture first interrupt from the infinete loop(denoted as HERE HERE HERE) but unexpectedly it never reverts to the main, i mean to the infinete loop. it stays inside the interrupt till completion of the trasmission of "array ch"

What about this?

#include
int count=0;char ch[]={'m',0X76,7};
void setclk();
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
setclk();

P2SEL |= 0x30; // P2.4,5 = USART0 TXD/RXD
ME1 |= UTXE0 + URXE0; // Enable USART0 TXD/RXD
UCTL0 |= CHAR; // 8-bit character
UTCTL0 |= SSEL1+TXWAKE; // UCLK = SMCLK
UBR00 = 0x6D; // 1MHz 9600
UBR10 = 0x00; //
UMCTL0 = 0x03; // Modulation
UCTL0 &= ~SWRST; // Initialize USART state machine
IE1 |= UTXIE0; // Enable USART0 RX interrupt
P2DIR |= 0x10; // P2.4 output direction

_EINT();
while(1){ } //HERE HERE HERE
}

#pragma vector=USART0TX_VECTOR
__interrupt void usart0_tx (void)
{
//while (!(IFG1 & UTXIFG0));
if(count<3)
{ TXBUF0 =ch[count++]; }
}