This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Receive interrupt problem

Other Parts Discussed in Thread: MSP430F248

Hi,

I am usinf msp430f248. I can successfully use transmit interrupt for serial communication, UART. But; i have problem with receive interrupt. I can send data but not receive. As i see; the incoming data is received in UCA0RXBUF but that does not trigger the USCI0RX_ISR although the receive interrupt and global interrupts are enabled. What the problem may be?

  • Hi,

           How do u know u r receiving the data did u check on the hardware debugging  ( or simulation ) on Compiler  or try to check that once on Oscilloscope whether u r getting the data receive or not.

    and If u r really getting the data but if the flag is unable to trigger the ISR  then check the latest ERRATA data sheet of u r particular MSPxx series U might find a solution or workaround so that u can rectify the problem

  • Hi,

    ever thought about testing your Hardware with an application example from TI - maybe msp430x24x_uscia0_uart_01_19200.c (USCI_A0, 19200 UART Echo ISR, DCO SMCLK)? You can find the C-Samples for MSP430F248 here --> http://www.ti.com/litv/zip/slac149d .

    Rgds
    G**kbuster

  • Hi,

    I have tried the SAMPLE CODES of TI but even they did NOT WORK! I checked wheter i can receive data without interrupt as follows; i opened the hyper terminal window and also msp430 started to run, in the main code it transmits the data in the UCA0RXBUF (the buffer in which the received data by UART is stored). That is; if some data received from the hyper terminal, that data is stored in UCA0RXBUF and msp430 sends it back to the hyper terminal, a simple ECHO program without receive interrupt. That program worked! Received data can be stored into UCA0RXBUF but that does not trigger interrupt however. I have tried several sample codes and also several msp430 devices but again the result was the same. The main code and the interrupt vector is below:

    Device: msp430f248

    int main(void)

    {

      WDTCTL = WDTPW + WDTHOLD;                 // Stop watchdog timer

      SCI_init(0,false,104,1);  // USCI_A0, 9600 baud, 1 MHz DCO

      while(1){

           SCI_writeChar(0, UCA0RXBUF); // if a char is received from hyper terminal echo it

      }

    }

     

    // USCI A0/B0 Receive ISR

    #pragma vector=USCIAB0RX_VECTOR 

    __interrupt void USCI0RX_ISR(void)

    {

      char c;

    // take the byte from receive data buffer

      c=UCA0RXBUF;

    // and push it the queue

      qrb_enqueue(&SCI_in_buffer[0], c, FALSE);

    }

  • did you try the sample code as is or did you try and add it to your existing code?? if you added it tou your existing cde, try the sample as is..

    Many times TI sample code depends on the defaut values at powerup instead of exlicitly seting the values, you can be changing a register value that will effect the operation..

     

     

  • I do not see where you enabled the global interrupt enable, something like this:

      __bis_SR_register(GIE);       // interrupts enabled

    nor where you enabled your UART receive interrupt, something like this:

    UCA0IE |= UCRXIE;                         // Enable USCI_A0 RX interrupt

    All of the above are from the sample codes.

  • Hi,

    I used the sample codes as they are but they did not work. I also make the global and receive interrupts enable operation in the function SCI_init(). Receive interrupt does not work although it is enabled. The function is below.

    void SCI_init(int serialNo, BOOL extOscillator, int baudRateDivider, int intFrequency)

    {

    if(serialNo==0){

       qrb_init(&SCI_in_buffer[0]);

       qrb_init(&SCI_out_buffer[0]);

       UCA0CTL1 &= UCSWRST;

       P3SEL = 0x30;   // P3.4,5 = USCI_A0 TXD/RXD

       P3DIR = 0x10; // P3.4 out

      // clock and baud rate will be adjusted

      // if ext watch crystal is used

      // baudRate Divider = freq. / baud rate

      // ex: 32768 Hz / 9600

      // write it to the baud rate control register

       if(extOscillator){

       UCA0CTL1 |= UCSSEL_1;   // CLK = ACLK

       UCA0BR0 = baudRateDivider%256; // BaudRate control register

       UCA0BR1 = baudRateDivider/256;  //

       UCA0MCTL = UCBRS1 + UCBRS0;       // Modulation UCBRSx = 3

       }

      

       // if DCO is used

       else{

       UCA0CTL1 |= UCSSEL_2; // SMCLK

       UCA0BR0 = baudRateDivider%256; // BaudRate control register

       UCA0BR1 = baudRateDivider/256;  //

      

    switch(intFrequency)

    {

    case(1):

    BCSCTL1 = CALBC1_1MHZ;     // Set DCO

       DCOCTL = CALDCO_1MHZ;

       break;

      

       case(8):

    BCSCTL1 = CALBC1_8MHZ;     

       DCOCTL = CALDCO_8MHZ;

       break;

      

       case(12):

    BCSCTL1 = CALBC1_12MHZ;     

       DCOCTL = CALDCO_12MHZ;

       break;

      

       case(16):

    BCSCTL1 = CALBC1_16MHZ;     

       DCOCTL = CALDCO_16MHZ;

       break;

    }

    UCA0MCTL = UCBRS0 + UCBRS2;  // Modulation UCBRSx = 1

       }

    UCA0CTL1 &= ~UCSWRST;   // **Initialize USCI state machine**

    IE2 |= UCA0RXIE;  // Enable USCI_A0 RX interrupt

    IFG2 &= ~UCA0RXIFG;

    }

     

    __bis_SR_register(GIE); // Global interrupts enable

    }

  • Looking at your code, it seems that in the function

    SCI_init(0,false,104,1);  // USCI_A0, 9600 baud, 1 MHz DCO

     

    void SCI_init(int serialNo, BOOL extOscillator, int baudRateDivider, int intFrequency)

    {

    if(serialNo==0){

       qrb_init(&SCI_in_buffer[0]);

       qrb_init(&SCI_out_buffer[0]);

       UCA0CTL1 &= UCSWRST;

     

    the line  UCA0CTL1 &= UCSWRST does nothing.  If you are trying to set the bit, use the 'OR' operation  A |= B.  Also, you can check if perhaps the interrupt is not triggering because the received data is in an erroneous format.  By default, the hardware module rejects data that doesn't fit the appropriate data format of start, data, parity, and stop bits.  To allow the interrupt to trigger on data that is improperly formatted you can set the UCRXEIE bit in the UCAxCTL1 register which will allow the USCI to generate an interrupt for any data that comes to the port.

  • Hi,

    I have solved the problem, in fact it is a comic reason in the settings of hyper terminal :)

  • hi jedi,

    I am kinda having the same problem as you had. I have connection between the ED and the AP but I wanna see the data from the ED to AP at the hyper-terminal. You know what I mean?  I would like to see the data streaming in continuously at the hyper-terminal. 

**Attention** This is a public forum