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.

MSP430 ISR entry and exit

Hello;

 

I am using XMS430F5438 for developing my new application. For validation od code, i am using MSP-EXP430F5438 development board. My program is as follows:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

#include

 

 

 

volatile

 

 

volatile

 

 

void

 

 

WDTCTL = WDTPW | WDTHOLD;

 

// Stop WDT

P3SEL = 0x30;

 

// P3.4,5 = USCI_A0 TXD/RXD

UCA0CTL1 |= UCSWRST;

 

// **Put state machine in reset**

UCA0CTL1 |= UCSSEL_1;

 

// CLK = ACLK

UCA0BR0 = 0x03;

 

// 32kHz/9600=3.41 (see User's Guide)

UCA0BR1 = 0x00;

 

//

UCA0MCTL = UCBRS_3 | UCBRF_0;

 

// Modulation UCBRSx=3, UCBRFx=0

UCA0CTL1 &= ~UCSWRST;

 

// **Initialize USCI state machine**

UCA0IE |= UCRXIE;

 

// Enable USCI_A0 RX interrupt

UCA0IE |= UCTXIE;

 

// Enable USCI_A0 RX interrupt

 

 

 

for (i = 0; i <= 40; i++);

 

__bis_SR_register(LPM0_bits + GIE);

 

// Enter LPM0, interrupts enabled

__no_operation();

 

// For debugger

}

 

 

 

 

// Echo back RXed character, confirm TX buffer is ready first

#pragma

 

 

void USCI_A0_ISR(void)

{

 

 

switch (__even_in_range(UCA0IV,4))

{

 

 

case 0: break;

// Vector 0 - no interrupt

 

 

case 2:

// Vector 2 - RXIFG

// while (!(UCA0IFG & UCTXIFG)); // USCI_A0 TX buffer ready ?

// while (!UCRXIFG); // USCI_A0 TX buffer ready ?

Rx_Data = UCA0RXBUF;

 

// TX -> RXed character

 

 

break;

 

 

case 4: UCA0TXBUF = 0x6A;

// TX -> 0x5A character

// while (!UCTXIFG); // USCI_A0 TX buffer ready ?

 

 

break;

// Vector 4 - TXIFG

 

 

default: break;

}

}

This program transmits character on UART. The program works as follows:

1. UART is configured to communicate at 9600 baud. UART works on ACLK = 32.768 Hz. 38768/9600 = 3.41.

2.   After the UART is configured for communication at 9600 baud, an interrupt occurs. Hence an ISR is called by reading UCA0IV register through __interrupt intrinsic of CCSV4. In the ISR, condition 4 is satisfied and 0x6A is transmitted on UART only once. After the character transfer, the program control should come out of ISR and return to main () function. But this is not happening.

vector = USCI_A0_VECTOR

__interrupt

RS232_UART (void)

{

unsigned int i;

 

 

unsigned int Rx_Data;
"xms430f5438.h"

#include

 

"RS232_UART.h"

 

 

My problem is as follows:

1.  The program control does not comes out of ISR. It loops inside the ISR indefinitely and does not return to main () function. I have checked following registers:

UCA0IV --- At the end of ISR UCA0IV = 0x0000

UCATXIFG --- At the end of ISR UCATXIFG = 0

After this the program control returns to __interrupt statement at the beginning of the program.

How to solve this problem, what is wrong in this program ?

Thanks in Advance...

--- Sunil

  • Hi Sunil,

    I'm sorry, since the formatting of your code got scrambled I'm unable to help you. Pls repost your code and:

    - Place your question on top of it

    - Do not copy the code directly from CCS to the forum. It is better to copy&paste it from CCS into an editor, and then copy&paste it into the post. This will keep your code formatted.

    Rgds
    aBUGSworstnightmare

**Attention** This is a public forum