EmbeddedRelated.com
Forums

Problem with USCIA0_TX interrupt for MSP430F2418

Started by ti2tt February 26, 2009
Hello Forum members,

I am using MSP430F2418 with CrossStudio for my project. I have
configured USCIA0 for UART mode. When I debug the code, I found that
the ISR for UART transmit is served all the time and the code remains
in treat_transmitted_frame() routine and other code from main while
loop does not get executed. If I does not enable TX interrupt in
InitUART0, the while loop in main gets executed. What other settings
are required to configure the USCI in UART mode? Please clarify. Your
earliest help in this regard will be highly appreciated. Following
are the configuration routines:

void InitUART0 (void)
{
UCA0CTL1 |= UCSWRST;
//UCA0CTL0 |= UCPEN;
UCA0CTL1 |= (UCSSEL_1);
UCA0BR0 = 0x41;
UCA0BR1 = 0x03;
UCA0MCTL = UCBRS_3;
P3SEL |= 0x30; // Select System
functionality for RXD0 and TXD0
UCA0CTL1 &= ~UCSWRST;
IE2 |= UCA0RXIE; //(UCA0TXIE | ); // Enable UART0 TX,
RX interrupt
IE2 |= UCA0TXIE;
}

void ISR_UART0RX (void) INTERRUPT[USCIAB0RX_VECTOR]
{
UCHAR scistatus;
scistatus = UCA0STAT;
treat_received_frame(scistatus); // treat received character
}

void ISR_UART0TX (void) INTERRUPT[USCIAB0TX_VECTOR]
{
treat_transmitted_frame(); // treat transmit character
}

Thanks in advance.

Beginning Microcontrollers with the MSP430

Hello Members,

No reply for my query. Had I correctly described the problem? I have
forgotten to include the main routine. It is as:
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
_DINT();
InitUART0();
_EINT();

while(1)
{
}
}

After _EINT, code doesn't enter while loop and if debugged, it is
found that it loops in TX ISR only. Can anyone try this and help me
out? This logic has worked for MSP430F1611 but I am facing some
issues in configuring the MSP430F2418 UART. Can anyone help me out?

Thanks in advance.
--- In m..., "ti2tt" wrote:
>
> Hello Forum members,
>
> I am using MSP430F2418 with CrossStudio for my project. I have
> configured USCIA0 for UART mode. When I debug the code, I found
that
> the ISR for UART transmit is served all the time and the code
remains
> in treat_transmitted_frame() routine and other code from main while
> loop does not get executed. If I does not enable TX interrupt in
> InitUART0, the while loop in main gets executed. What other
settings
> are required to configure the USCI in UART mode? Please clarify.
Your
> earliest help in this regard will be highly appreciated. Following
> are the configuration routines:
>
> void InitUART0 (void)
> {
> UCA0CTL1 |= UCSWRST;
> //UCA0CTL0 |= UCPEN;
> UCA0CTL1 |= (UCSSEL_1);
> UCA0BR0 = 0x41;
> UCA0BR1 = 0x03;
> UCA0MCTL = UCBRS_3;
> P3SEL |= 0x30; // Select System
> functionality for RXD0 and TXD0
> UCA0CTL1 &= ~UCSWRST;
> IE2 |= UCA0RXIE; //(UCA0TXIE | ); // Enable UART0 TX,
> RX interrupt
> IE2 |= UCA0TXIE;
> }
>
> void ISR_UART0RX (void) INTERRUPT[USCIAB0RX_VECTOR]
> {
> UCHAR scistatus;
> scistatus = UCA0STAT;
> treat_received_frame(scistatus); // treat received character
> }
>
> void ISR_UART0TX (void) INTERRUPT[USCIAB0TX_VECTOR]
> {
> treat_transmitted_frame(); // treat transmit character
> }
>
> Thanks in advance.
>

I might be wrong, but since I don't know the code for
treat_transmitted_frame(), I'll tell you what I think:
The problem is not in using a different device, but rater that you
don't understand how the TX interrupt flag works: it is set by
hardware WHENEVER the TX buffer is empty. That includes PUC, which
means that by enabling TX interrupts in InitUART0(), as soon as you
enable GIE the TX ISR is triggered. If treat_transmitted_frame()
doesn't fill the TX buffer, the TX flag will not be cleared, therefore
as soon as the program returns from the ISR, it will go right into it
again and you will never reach while(1).
In order to use the TX interrupt, you need to enable it when you want
to start transmitting a packet, and disable it in the ISR right after
the last byte has been written to the TX buffer.

Regards,
Michael K.

--- In m..., "ti2tt" wrote:
>
> Hello Members,
>
> No reply for my query. Had I correctly described the problem? I have
> forgotten to include the main routine. It is as:
> void main(void)
> {
> WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
> _DINT();
> InitUART0();
> _EINT();
>
> while(1)
> {
> }
> }
>
> After _EINT, code doesn't enter while loop and if debugged, it is
> found that it loops in TX ISR only. Can anyone try this and help me
> out? This logic has worked for MSP430F1611 but I am facing some
> issues in configuring the MSP430F2418 UART. Can anyone help me out?
>
> Thanks in advance.
> --- In m..., "ti2tt" wrote:
> >
> > Hello Forum members,
> >
> > I am using MSP430F2418 with CrossStudio for my project. I have
> > configured USCIA0 for UART mode. When I debug the code, I found
> that
> > the ISR for UART transmit is served all the time and the code
> remains
> > in treat_transmitted_frame() routine and other code from main while
> > loop does not get executed. If I does not enable TX interrupt in
> > InitUART0, the while loop in main gets executed. What other
> settings
> > are required to configure the USCI in UART mode? Please clarify.
> Your
> > earliest help in this regard will be highly appreciated. Following
> > are the configuration routines:
> >
> > void InitUART0 (void)
> > {
> > UCA0CTL1 |= UCSWRST;
> > //UCA0CTL0 |= UCPEN;
> > UCA0CTL1 |= (UCSSEL_1);
> > UCA0BR0 = 0x41;
> > UCA0BR1 = 0x03;
> > UCA0MCTL = UCBRS_3;
> > P3SEL |= 0x30; // Select System
> > functionality for RXD0 and TXD0
> > UCA0CTL1 &= ~UCSWRST;
> > IE2 |= UCA0RXIE; //(UCA0TXIE | ); // Enable UART0 TX,
> > RX interrupt
> > IE2 |= UCA0TXIE;
> > }
> >
> > void ISR_UART0RX (void) INTERRUPT[USCIAB0RX_VECTOR]
> > {
> > UCHAR scistatus;
> > scistatus = UCA0STAT;
> > treat_received_frame(scistatus); // treat received character
> > }
> >
> > void ISR_UART0TX (void) INTERRUPT[USCIAB0TX_VECTOR]
> > {
> > treat_transmitted_frame(); // treat transmit character
> > }
> >
> > Thanks in advance.
>

Hello Michael,

Thanks for your reply. As you said, I must use the TX interrupt
whenever I need to transmit the data and disable it immediatly after
transmission is over.

With 1MHz BRCLK and 1200 baud, I have configured the MSP430F2418 to
receive the data from PC com port. The init part for UART is as:
void InitUART0 (void)
{
UCA0CTL1 |= UCSWRST;
//UCA0CTL0 |= UCPEN;
UCA0CTL1 |= (UCSSEL_1);
UCA0BR0 = 0x41;
UCA0BR1 = 0x03;
UCA0MCTL = UCBRS_3;
P3SEL |= 0x30; // Select System functionality for RXD0 and TXD0
UCA0CTL1 &= ~UCSWRST;
IE2 |= UCA0RXIE;
}

but still I am missing some of the bytes. Has anyone experinced this
problem with MSP430F2418 baud calculation? The baud calculation for
this uC is bit tedious. Is the error calculation is required to be
done for this? Has anyone data for this at different baud rates?

Thanks in advance.

--- In m..., "tintronic" wrote:
>
> I might be wrong, but since I don't know the code for
> treat_transmitted_frame(), I'll tell you what I think:
> The problem is not in using a different device, but rater that you
> don't understand how the TX interrupt flag works: it is set by
> hardware WHENEVER the TX buffer is empty. That includes PUC, which
> means that by enabling TX interrupts in InitUART0(), as soon as you
> enable GIE the TX ISR is triggered. If treat_transmitted_frame()
> doesn't fill the TX buffer, the TX flag will not be cleared,
therefore
> as soon as the program returns from the ISR, it will go right into
it
> again and you will never reach while(1).
> In order to use the TX interrupt, you need to enable it when you
want
> to start transmitting a packet, and disable it in the ISR right
after
> the last byte has been written to the TX buffer.
>
> Regards,
> Michael K.
>
> --- In m..., "ti2tt" wrote:
> >
> > Hello Members,
> >
> > No reply for my query. Had I correctly described the problem? I
have
> > forgotten to include the main routine. It is as:
> > void main(void)
> > {
> > WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
> > _DINT();
> > InitUART0();
> > _EINT();
> >
> > while(1)
> > {
> > }
> > }
> >
> > After _EINT, code doesn't enter while loop and if debugged, it is
> > found that it loops in TX ISR only. Can anyone try this and help
me
> > out? This logic has worked for MSP430F1611 but I am facing some
> > issues in configuring the MSP430F2418 UART. Can anyone help me
out?
> >
> > Thanks in advance.
> > --- In m..., "ti2tt" wrote:
> > >
> > > Hello Forum members,
> > >
> > > I am using MSP430F2418 with CrossStudio for my project. I have
> > > configured USCIA0 for UART mode. When I debug the code, I found
> > that
> > > the ISR for UART transmit is served all the time and the code
> > remains
> > > in treat_transmitted_frame() routine and other code from main
while
> > > loop does not get executed. If I does not enable TX interrupt
in
> > > InitUART0, the while loop in main gets executed. What other
> > settings
> > > are required to configure the USCI in UART mode? Please
clarify.
> > Your
> > > earliest help in this regard will be highly appreciated.
Following
> > > are the configuration routines:
> > >
> > > void InitUART0 (void)
> > > {
> > > UCA0CTL1 |= UCSWRST;
> > > //UCA0CTL0 |= UCPEN;
> > > UCA0CTL1 |= (UCSSEL_1);
> > > UCA0BR0 = 0x41;
> > > UCA0BR1 = 0x03;
> > > UCA0MCTL = UCBRS_3;
> > > P3SEL |= 0x30; // Select System
> > > functionality for RXD0 and TXD0
> > > UCA0CTL1 &= ~UCSWRST;
> > > IE2 |= UCA0RXIE; //(UCA0TXIE | ); // Enable
UART0 TX,
> > > RX interrupt
> > > IE2 |= UCA0TXIE;
> > > }
> > >
> > > void ISR_UART0RX (void) INTERRUPT[USCIAB0RX_VECTOR]
> > > {
> > > UCHAR scistatus;
> > > scistatus = UCA0STAT;
> > > treat_received_frame(scistatus); // treat received
character
> > > }
> > >
> > > void ISR_UART0TX (void) INTERRUPT[USCIAB0TX_VECTOR]
> > > {
> > > treat_transmitted_frame(); // treat transmit
character
> > > }
> > >
> > > Thanks in advance.
> > >
>

ti2tt,

I don't know if this will help, but I am including a serial port I/O routine
that I have tested on the TI MSP-EXP430FG4618 (Experimenter Board, which has
RS232 output) and the MSP430F2618 (mounted in a TI 64-pin socket board with
RS232 inverter/level shifters added, externally). I tested by plugging each
into a PC and running HyperTerm. At startup, a sign-on message is displayed,
then chars typed on the PC are echoed back. Each of these boards has a 32kHz
watch crystal, which is used for the bit-rate clock. Note that the port is
setup for 1200, 7, e, 1.

Note also, that IAR accepts the putchar() replacement. Sure does bloat the
code size when you use the library routines for formatted I/O, such sprintf,
printf, etc. Later, I will probably do my own formatting and save something
on the order of 5K to 6K of code space. Right now, however, code size (and
execution time) is not of primary concern, so I'll just stick with the
convenience of using the library routines.

More on low-level I/O:
>From the IAR IDE, under Help | MSP430 C/C++ Reference Guide | Part 1. Using
the compiler | The DLIB runtime environment | Standard streams for input and
output | Implementing low-level input and output | Example of using __write
and __read, you will find the "Proper" way of doing the low-level I/O, using
templates for __write and __read in your tool chain's 430\src\lib. Although
I did not include this solution below, but used the putchar replacement
instead, I have tried "Proper" way, and it works. I have not found the
"Proper" way to do the low-level I/O using CCE, however. I do know that
simply replacing putchar doesn't work in CCE. If anyone has successfully
done the low-level I/O replacement routines in CCE, maybe they will share
with us.

Jim Smith

// ****** TestSerIO.c ********************************************
#include "msp430.h" // Selects include file(s) based on IDE defined target
#include "stdio.h"
// ***************************************************************
void InitTIMERB0(void){ // will be used later for System Timer-Tick
TBCCTL0 = CCIE; // TBCCR0 interrupt enabled
TBCCR0 = 32768; // 1-second interrupt
TBCTL = (TBSSEL_1 | MC_2); // TBCLKLK2kHz, cont mode.
} // end of InitTIMERB0
// ***************************************************************
void InitUART0(void) {
UCA0CTL1 = ( UCSSEL_1 // UART, CLK = ACLK (32kHz)
| UCSWRST ); // Hold the module in reset
UCA0BR0 = 27; // 1200 baud: 32768/1200 = 27.31
UCA0BR1 = 0; //
UCA0MCTL = UCBRS_2; // Modulation UCBRSx = 2 (UG pg 15-30)
UCA0CTL0 |= ( UCPEN // Parity Enable
| UCPAR // Even Parity
| UC7BIT ); // 7-Bit char length
P3SEL |= (BIT4 | BIT5); // P3.4,5 = USCI_A0 TXD/RXD
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
IE2 |= UCA0RXIE; // Ensable USART0 RX interrupt
} // end of InitUART0
// ***************************************************************
// putchar() replacement, gets linked in instead of the lib routine
// IAR, defined in stdio.h: MEMORY_ATTRIBUTE int putchar(int);
// ***************************************************************
int putchar(int c) {
while(!(IFG2 & UCA0TXIFG)); // wait for USART TX buffer ready
UCA0TXBUF = c; // Load char in TX buffer
return c; // return the transmitted value
} // end of putchar
// ***************************************************************
void main(void) {
WDTCTL = WDTPW + WDTHOLD; // Stop Watchdog Timer
P1DIR |= (BIT0); // P1.0 is output, to LED
InitTIMERB0(); // Initialize System Timer-tick
InitUART0(); // Initialize USCI_A0 for UART
// Test Serial output
printf("\r\nSignon: This prints to Serial Port\r\n");
__enable_interrupt(); // Now, let the interrupts happen
while (1) { // Begin main's loop-forever
// Do any req'd processing
__low_power_mode_3(); // Enter LPM3
__no_operation(); // placeholder for debugger
} // end of main's forever loop
} // end of main
// ***************************************************************
#pragma vector=TIMERB0_VECTOR
__interrupt void Timer_B0_ISR (void){ // TimerB0 interrupt service routine
P1OUT ^= 0x01; // Toggle the LED (P1.0)
TBCCR0 += 32768; // Add 1-second Offset to TBCCR0
__low_power_mode_off_on_exit();
} // end of Timer_B0_ISR
// ***************************************************************
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{
// The TX buffer should be ready, but, to be safe, test it.
// Later, implement buffered, interrupt driven serial input/output
while(!(IFG2 & UCA0TXIFG)); // wait for USART TX buffer ready
UCA0TXBUF = UCA0RXBUF; // Echo the received char
__low_power_mode_off_on_exit();
} // end of USCI0RX_ISR
// ***** end TstSerIO.c ******************************************
_____

From: m... [mailto:m...] On Behalf Of
ti2tt
Sent: Monday, March 02, 2009 9:47 AM
To: m...
Subject: [msp430] Re: Problem with USCIA0_TX interrupt for MSP430F2418

Hello Michael,

Thanks for your reply. As you said, I must use the TX interrupt
whenever I need to transmit the data and disable it immediatly after
transmission is over.

With 1MHz BRCLK and 1200 baud, I have configured the MSP430F2418 to
receive the data from PC com port. The init part for UART is as:
void InitUART0 (void)
{
UCA0CTL1 |= UCSWRST;
//UCA0CTL0 |= UCPEN;
UCA0CTL1 |= (UCSSEL_1);
UCA0BR0 = 0x41;
UCA0BR1 = 0x03;
UCA0MCTL = UCBRS_3;
P3SEL |= 0x30; // Select System functionality for RXD0 and TXD0
UCA0CTL1 &= ~UCSWRST;
IE2 |= UCA0RXIE;
}

but still I am missing some of the bytes. Has anyone experinced this
problem with MSP430F2418 baud calculation? The baud calculation for
this uC is bit tedious. Is the error calculation is required to be
done for this? Has anyone data for this at different baud rates?

Thanks in advance.

--- In msp430@yahoogroups. com,
"tintronic" wrote:
>
> I might be wrong, but since I don't know the code for
> treat_transmitted_frame(), I'll tell you what I think:
> The problem is not in using a different device, but rater that you
> don't understand how the TX interrupt flag works: it is set by
> hardware WHENEVER the TX buffer is empty. That includes PUC, which
> means that by enabling TX interrupts in InitUART0(), as soon as you
> enable GIE the TX ISR is triggered. If treat_transmitted_frame()
> doesn't fill the TX buffer, the TX flag will not be cleared,
therefore
> as soon as the program returns from the ISR, it will go right into
it
> again and you will never reach while(1).
> In order to use the TX interrupt, you need to enable it when you
want
> to start transmitting a packet, and disable it in the ISR right
after
> the last byte has been written to the TX buffer.
>
> Regards,
> Michael K.
>
> --- In msp430@yahoogroups. com, "ti2tt"
wrote:
> >
> > Hello Members,
> >
> > No reply for my query. Had I correctly described the problem? I
have
> > forgotten to include the main routine. It is as:
> > void main(void)
> > {
> > WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
> > _DINT();
> > InitUART0();
> > _EINT();
> >
> > while(1)
> > {
> > }
> > }
> >
> > After _EINT, code doesn't enter while loop and if debugged, it is
> > found that it loops in TX ISR only. Can anyone try this and help
me
> > out? This logic has worked for MSP430F1611 but I am facing some
> > issues in configuring the MSP430F2418 UART. Can anyone help me
out?
> >
> > Thanks in advance.
> > --- In msp430@yahoogroups. com,
"ti2tt" wrote:
> > >
> > > Hello Forum members,
> > >
> > > I am using MSP430F2418 with CrossStudio for my project. I have
> > > configured USCIA0 for UART mode. When I debug the code, I found
> > that
> > > the ISR for UART transmit is served all the time and the code
> > remains
> > > in treat_transmitted_frame() routine and other code from main
while
> > > loop does not get executed. If I does not enable TX interrupt
in
> > > InitUART0, the while loop in main gets executed. What other
> > settings
> > > are required to configure the USCI in UART mode? Please
clarify.
> > Your
> > > earliest help in this regard will be highly appreciated.
Following
> > > are the configuration routines:
> > >
> > > void InitUART0 (void)
> > > {
> > > UCA0CTL1 |= UCSWRST;
> > > //UCA0CTL0 |= UCPEN;
> > > UCA0CTL1 |= (UCSSEL_1);
> > > UCA0BR0 = 0x41;
> > > UCA0BR1 = 0x03;
> > > UCA0MCTL = UCBRS_3;
> > > P3SEL |= 0x30; // Select System
> > > functionality for RXD0 and TXD0
> > > UCA0CTL1 &= ~UCSWRST;
> > > IE2 |= UCA0RXIE; //(UCA0TXIE | ); // Enable
UART0 TX,
> > > RX interrupt
> > > IE2 |= UCA0TXIE;
> > > }
> > >
> > > void ISR_UART0RX (void) INTERRUPT[USCIAB0RX_VECTOR]
> > > {
> > > UCHAR scistatus;
> > > scistatus = UCA0STAT;
> > > treat_received_frame(scistatus); // treat received
character
> > > }
> > >
> > > void ISR_UART0TX (void) INTERRUPT[USCIAB0TX_VECTOR]
> > > {
> > > treat_transmitted_frame(); // treat transmit
character
> > > }
> > >
> > > Thanks in advance.
> > >
>

No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.0.237 / Virus Database: 270.11.5/1979 - Release Date: 03/01/09
17:46:00



Hi All/Jim,

Firstly sorry for replying late.

I have created a project for MSP430F2418 to receive characters on receive interrupt. If I use IAR workbench for MSP v4 IDE for this project to debug, I receive all the characters on RX line but if I use CrossStudio v2.0, some of the characters are missing. Others are coming correct (so no issue of baud). By some of the characters here, I mean no. of characters. If I am receiving 25 characters with IAR IDE, then with CrossStudio I am receiving only 10-12 characters. Others are missing. Has anyone experienced this kind of problem? I need very urgent help from forum as I am stucked in this issue.

Thanks in advance.

--- In m..., "Jim Smith" wrote:
>
> ti2tt,
>
> I don't know if this will help, but I am including a serial port I/O routine
> that I have tested on the TI MSP-EXP430FG4618 (Experimenter Board, which has
> RS232 output) and the MSP430F2618 (mounted in a TI 64-pin socket board with
> RS232 inverter/level shifters added, externally). I tested by plugging each
> into a PC and running HyperTerm. At startup, a sign-on message is displayed,
> then chars typed on the PC are echoed back. Each of these boards has a 32kHz
> watch crystal, which is used for the bit-rate clock. Note that the port is
> setup for 1200, 7, e, 1.
>
> Note also, that IAR accepts the putchar() replacement. Sure does bloat the
> code size when you use the library routines for formatted I/O, such sprintf,
> printf, etc. Later, I will probably do my own formatting and save something
> on the order of 5K to 6K of code space. Right now, however, code size (and
> execution time) is not of primary concern, so I'll just stick with the
> convenience of using the library routines.
>
> More on low-level I/O:
> From the IAR IDE, under Help | MSP430 C/C++ Reference Guide | Part 1. Using
> the compiler | The DLIB runtime environment | Standard streams for input and
> output | Implementing low-level input and output | Example of using __write
> and __read, you will find the "Proper" way of doing the low-level I/O, using
> templates for __write and __read in your tool chain's 430\src\lib. Although
> I did not include this solution below, but used the putchar replacement
> instead, I have tried "Proper" way, and it works. I have not found the
> "Proper" way to do the low-level I/O using CCE, however. I do know that
> simply replacing putchar doesn't work in CCE. If anyone has successfully
> done the low-level I/O replacement routines in CCE, maybe they will share
> with us.
>
> Jim Smith
>
> // ****** TestSerIO.c ********************************************
> #include "msp430.h" // Selects include file(s) based on IDE defined target
> #include "stdio.h"
> // ***************************************************************
> void InitTIMERB0(void){ // will be used later for System Timer-Tick
> TBCCTL0 = CCIE; // TBCCR0 interrupt enabled
> TBCCR0 = 32768; // 1-second interrupt
> TBCTL = (TBSSEL_1 | MC_2); // TBCLKLK2kHz, cont mode.
> } // end of InitTIMERB0
> // ***************************************************************
> void InitUART0(void) {
> UCA0CTL1 = ( UCSSEL_1 // UART, CLK = ACLK (32kHz)
> | UCSWRST ); // Hold the module in reset
> UCA0BR0 = 27; // 1200 baud: 32768/1200 = 27.31
> UCA0BR1 = 0; //
> UCA0MCTL = UCBRS_2; // Modulation UCBRSx = 2 (UG pg 15-30)
> UCA0CTL0 |= ( UCPEN // Parity Enable
> | UCPAR // Even Parity
> | UC7BIT ); // 7-Bit char length
> P3SEL |= (BIT4 | BIT5); // P3.4,5 = USCI_A0 TXD/RXD
> UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
> IE2 |= UCA0RXIE; // Ensable USART0 RX interrupt
> } // end of InitUART0
> // ***************************************************************
> // putchar() replacement, gets linked in instead of the lib routine
> // IAR, defined in stdio.h: MEMORY_ATTRIBUTE int putchar(int);
> // ***************************************************************
> int putchar(int c) {
> while(!(IFG2 & UCA0TXIFG)); // wait for USART TX buffer ready
> UCA0TXBUF = c; // Load char in TX buffer
> return c; // return the transmitted value
> } // end of putchar
> // ***************************************************************
> void main(void) {
> WDTCTL = WDTPW + WDTHOLD; // Stop Watchdog Timer
> P1DIR |= (BIT0); // P1.0 is output, to LED
> InitTIMERB0(); // Initialize System Timer-tick
> InitUART0(); // Initialize USCI_A0 for UART
> // Test Serial output
> printf("\r\nSignon: This prints to Serial Port\r\n");
> __enable_interrupt(); // Now, let the interrupts happen
> while (1) { // Begin main's loop-forever
> // Do any req'd processing
> __low_power_mode_3(); // Enter LPM3
> __no_operation(); // placeholder for debugger
> } // end of main's forever loop
> } // end of main
> // ***************************************************************
> #pragma vector=TIMERB0_VECTOR
> __interrupt void Timer_B0_ISR (void){ // TimerB0 interrupt service routine
> P1OUT ^= 0x01; // Toggle the LED (P1.0)
> TBCCR0 += 32768; // Add 1-second Offset to TBCCR0
> __low_power_mode_off_on_exit();
> } // end of Timer_B0_ISR
> // ***************************************************************
> #pragma vector=USCIAB0RX_VECTOR
> __interrupt void USCI0RX_ISR(void)
> {
> // The TX buffer should be ready, but, to be safe, test it.
> // Later, implement buffered, interrupt driven serial input/output
> while(!(IFG2 & UCA0TXIFG)); // wait for USART TX buffer ready
> UCA0TXBUF = UCA0RXBUF; // Echo the received char
> __low_power_mode_off_on_exit();
> } // end of USCI0RX_ISR
> // ***** end TstSerIO.c ******************************************
> _____
>
> From: m... [mailto:m...] On Behalf Of
> ti2tt
> Sent: Monday, March 02, 2009 9:47 AM
> To: m...
> Subject: [msp430] Re: Problem with USCIA0_TX interrupt for MSP430F2418
>
> Hello Michael,
>
> Thanks for your reply. As you said, I must use the TX interrupt
> whenever I need to transmit the data and disable it immediatly after
> transmission is over.
>
> With 1MHz BRCLK and 1200 baud, I have configured the MSP430F2418 to
> receive the data from PC com port. The init part for UART is as:
> void InitUART0 (void)
> {
> UCA0CTL1 |= UCSWRST;
> //UCA0CTL0 |= UCPEN;
> UCA0CTL1 |= (UCSSEL_1);
> UCA0BR0 = 0x41;
> UCA0BR1 = 0x03;
> UCA0MCTL = UCBRS_3;
> P3SEL |= 0x30; // Select System functionality for RXD0 and TXD0
> UCA0CTL1 &= ~UCSWRST;
> IE2 |= UCA0RXIE;
> }
>
> but still I am missing some of the bytes. Has anyone experinced this
> problem with MSP430F2418 baud calculation? The baud calculation for
> this uC is bit tedious. Is the error calculation is required to be
> done for this? Has anyone data for this at different baud rates?
>
> Thanks in advance.
>
> --- In msp430@yahoogroups. com,
> "tintronic" wrote:
> >
> > I might be wrong, but since I don't know the code for
> > treat_transmitted_frame(), I'll tell you what I think:
> > The problem is not in using a different device, but rater that you
> > don't understand how the TX interrupt flag works: it is set by
> > hardware WHENEVER the TX buffer is empty. That includes PUC, which
> > means that by enabling TX interrupts in InitUART0(), as soon as you
> > enable GIE the TX ISR is triggered. If treat_transmitted_frame()
> > doesn't fill the TX buffer, the TX flag will not be cleared,
> therefore
> > as soon as the program returns from the ISR, it will go right into
> it
> > again and you will never reach while(1).
> > In order to use the TX interrupt, you need to enable it when you
> want
> > to start transmitting a packet, and disable it in the ISR right
> after
> > the last byte has been written to the TX buffer.
> >
> > Regards,
> > Michael K.
> >
> > --- In msp430@yahoogroups. com, "ti2tt"
> wrote:
> > >
> > > Hello Members,
> > >
> > > No reply for my query. Had I correctly described the problem? I
> have
> > > forgotten to include the main routine. It is as:
> > > void main(void)
> > > {
> > > WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
> > > _DINT();
> > > InitUART0();
> > > _EINT();
> > >
> > > while(1)
> > > {
> > > }
> > > }
> > >
> > > After _EINT, code doesn't enter while loop and if debugged, it is
> > > found that it loops in TX ISR only. Can anyone try this and help
> me
> > > out? This logic has worked for MSP430F1611 but I am facing some
> > > issues in configuring the MSP430F2418 UART. Can anyone help me
> out?
> > >
> > > Thanks in advance.
> > > --- In msp430@yahoogroups. com,
> "ti2tt" wrote:
> > > >
> > > > Hello Forum members,
> > > >
> > > > I am using MSP430F2418 with CrossStudio for my project. I have
> > > > configured USCIA0 for UART mode. When I debug the code, I found
> > > that
> > > > the ISR for UART transmit is served all the time and the code
> > > remains
> > > > in treat_transmitted_frame() routine and other code from main
> while
> > > > loop does not get executed. If I does not enable TX interrupt
> in
> > > > InitUART0, the while loop in main gets executed. What other
> > > settings
> > > > are required to configure the USCI in UART mode? Please
> clarify.
> > > Your
> > > > earliest help in this regard will be highly appreciated.
> Following
> > > > are the configuration routines:
> > > >
> > > > void InitUART0 (void)
> > > > {
> > > > UCA0CTL1 |= UCSWRST;
> > > > //UCA0CTL0 |= UCPEN;
> > > > UCA0CTL1 |= (UCSSEL_1);
> > > > UCA0BR0 = 0x41;
> > > > UCA0BR1 = 0x03;
> > > > UCA0MCTL = UCBRS_3;
> > > > P3SEL |= 0x30; // Select System
> > > > functionality for RXD0 and TXD0
> > > > UCA0CTL1 &= ~UCSWRST;
> > > > IE2 |= UCA0RXIE; //(UCA0TXIE | ); // Enable
> UART0 TX,
> > > > RX interrupt
> > > > IE2 |= UCA0TXIE;
> > > > }
> > > >
> > > > void ISR_UART0RX (void) INTERRUPT[USCIAB0RX_VECTOR]
> > > > {
> > > > UCHAR scistatus;
> > > > scistatus = UCA0STAT;
> > > > treat_received_frame(scistatus); // treat received
> character
> > > > }
> > > >
> > > > void ISR_UART0TX (void) INTERRUPT[USCIAB0TX_VECTOR]
> > > > {
> > > > treat_transmitted_frame(); // treat transmit
> character
> > > > }
> > > >
> > > > Thanks in advance.
> > > >
> > >
> > No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 8.0.237 / Virus Database: 270.11.5/1979 - Release Date: 03/01/09
> 17:46:00
>
>

Maybe your code is not fast enough to receive all characters (i.e. some are overwritten before they are read from the USCI). You can detect this situation by testing the UCRXERR and UCOE bit.

--- In m..., "ti2tt" wrote:
I have created a project for MSP430F2418 to receive characters on receive interrupt. If I use IAR workbench for MSP v4 IDE for this project to debug, I receive all the characters on RX line but if I use CrossStudio v2.0, some of the characters are missing. Others are coming correct (so no issue of baud). By some of the characters here, I mean no. of characters. If I am receiving 25 characters with IAR IDE, then with CrossStudio I am receiving only 10-12 characters. Others are missing. Has anyone experienced this kind of problem? I need very urgent help from forum as I am stucked in this issue.

But I am using receive interrupt (ISR) to capture the data byte. Can this happen in interrupt based communication? If yes, after checking the UCRXERR and UCOE bits, what could be the solution for this erroneous communication? And why it is not happening in IAR?

Thanks in advance.
--- In m..., "distantship101" wrote:
>
> Maybe your code is not fast enough to receive all characters (i.e. some are overwritten before they are read from the USCI). You can detect this situation by testing the UCRXERR and UCOE bit.
>
> --- In m..., "ti2tt" wrote:
> I have created a project for MSP430F2418 to receive characters on receive interrupt. If I use IAR workbench for MSP v4 IDE for this project to debug, I receive all the characters on RX line but if I use CrossStudio v2.0, some of the characters are missing. Others are coming correct (so no issue of baud). By some of the characters here, I mean no. of characters. If I am receiving 25 characters with IAR IDE, then with CrossStudio I am receiving only 10-12 characters. Others are missing. Has anyone experienced this kind of problem? I need very urgent help from forum as I am stucked in this issue.
>

> > Maybe your code is not fast enough to receive all characters
> Can this happen in interrupt based communication?
Of course it can. An it WILL if you don't ensure timings are appropiate.
First, the whole ISR (going into, executing, returning from) has to be faster than the TX speed or you'll eventually lose some bytes. If transmission happens in bursts, you could check if a new byte has been received just before returning from the ISR, as not to waste time getting out and then back into the ISR. If you're using other interrupts, then you have to add all the ISR times together (at least all the ones that can happen at the same time) and that has to be faster than the character transmission rate.
I've had this issue and solved it reducing the (gprs modem) baud rate from 115200 bps to 57600, and later on down to 38400, as the UART communication speed was not a priority, but it had no flow control.

Michael K.

--- In m..., "ti2tt" wrote:
>
> But I am using receive interrupt (ISR) to capture the data byte. Can this happen in interrupt based communication? If yes, after checking the UCRXERR and UCOE bits, what could be the solution for this erroneous communication? And why it is not happening in IAR?
>
> Thanks in advance.
> --- In m..., "distantship101" wrote:
> >
> > Maybe your code is not fast enough to receive all characters (i.e. some are overwritten before they are read from the USCI). You can detect this situation by testing the UCRXERR and UCOE bit.
> >
> > --- In m..., "ti2tt" wrote:
> > I have created a project for MSP430F2418 to receive characters on receive interrupt. If I use IAR workbench for MSP v4 IDE for this project to debug, I receive all the characters on RX line but if I use CrossStudio v2.0, some of the characters are missing. Others are coming correct (so no issue of baud). By some of the characters here, I mean no. of characters. If I am receiving 25 characters with IAR IDE, then with CrossStudio I am receiving only 10-12 characters. Others are missing. Has anyone experienced this kind of problem? I need very urgent help from forum as I am stucked in this issue.
>