Help!What is wrong with my interrupt and transmission???

Im using msp430-rf2500-seh tool

Im trying to program an receive interrupt to get an integer from a anther board.

Here comes the problems:

  1. If i wanna enable an interrupt, i need to use P3SEL=0x30 (To select UART port P3.5).

  2. If i use P3SEL=0x30, End-device cant not transmit out. Everytime when i push the push button, the green led lights. But soon both leds light which means transmission failed.

I dunt understand why this simple interrupt can not be generated. Anybody can help me figure out what is gg on??? Tks in advance!

Plus, since im using the msp430rf2500 tool with solar panel, the P3.5 is reserved for detecting inner-battery flag. So Im juz diabling all the code related with inner-battery and fix a mode for msg locations.

Here is my code:

linkTo()

{

P3SEL = 0x3f; // If i put this one here, transmission will fail

BCSCTL1 = CALBC1_1MHZ; // Set DCO = 1MHz

DCOCTL = CALDCO_1MHZ;

UCA0CTL1 |= UCSSEL_2; // SMCLK

UCA0BR0 = 0x68; // 1MHz 9600

UCA0BR1 = 0; // 1MHz 9600

UCA0MCTL = UCBRF_0 + UCBRS_1 ; // Modulation UCBRSx = 1

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

IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt

__enable_interrupt();

}

#pragma vector=USCIAB0RX_VECTOR

__interrupt void USCI0RX_ISR(void)

{

aNumber = UCA0RXBUF; // TX → RXed character

IE2&=~UCA0RXIE;

}

It looks like you are not following the recommended guidelines for initializing the UART. Please refer to section 15.3.1 USCI Initialization and Reset of the MSP430x2xx Family Users Guide. See if that gets you working.

Tks for replying.

First,

I change

__enable_interrupt();

to

__bis_SR_register(GIE);

then test but transmission failed(Both leds light)

Then I try to follow the user guide:

The recommended USCI initialization/re-configuration process is:

  1. Set UCSWRST (BIS.B #UCSWRST,&UCAxCTL1)

  2. Initialize all USCI registers with UCSWRST = 1 (including UCAxCTL1)

  3. Configure ports.

  4. Clear UCSWRST via software (BIC.B #UCSWRST,&UCAxCTL1)

  5. Enable interrupts (optional) via UCAxRXIE and/or UCAxTXIE

I wrote my code:

BCSCTL1 = CALBC1_1MHZ; // Set DCO = 1MHz

DCOCTL = CALDCO_1MHZ;

UCA0CTL1 |= UCSSEL_2; // SMCLK

UCA0BR0 = 0x68; // 1MHz 9600

UCA0BR1 = 0; // 1MHz 9600

UCA0MCTL = UCBRF_0 + UCBRS_1 ; // Modulation UCBRSx = 1

UCA0CTL1 |= UCSWRST; //set the USCWRST

P3SEL = 0x3f;//configure ports

UCA0CTL1 &= ~UCSWRST;//clear uscwrst

IE2 |= UCA0RXIE;//Enable interrupt

__bis_SR_register(GIE);

After testing, transmission also failed. What is wrong???

P.S. I set aNumber= 11. When the imterrupt comes in, the value of aNumber should change.

I try another way – not using interrupt vector

BCSCTL1 = CALBC1_1MHZ; // Set DCO = 1MHz

DCOCTL = CALDCO_1MHZ;

UCA0CTL1 |= UCSSEL_2; // SMCLK

UCA0BR0 = 0x68; // 1MHz 9600

UCA0BR1 = 0; // 1MHz 9600

UCA0MCTL = UCBRF_0 + UCBRS_1 ; // Modulation UCBRSx = 1

UCA0CTL1 |= UCSWRST; //set the USCWRST

P3SEL |= 0x3f;//configure ports

UCA0CTL1 &= ~UCSWRST;//clear uscwrst

if(IFG2 & UCA0RXIFG)

{

aNumber = UCA0RXBUF;

}

else

{

aNumber=11;

}

Not working either… Anyone can help??? Tks in advance!

You still are not implementing the recommended initialization procedure; setting UCSWRST should be done before modifying any of the UCSI registers.

Please be specific. To say it is not working gives us no information to go on. What is it doing specifically? What are expecting? How are you troubleshooting? How is the hardware connected?

Hi! Tks so much for replying me.

I actually followed the sample code to setup the UCSWRST. :oops:

Anyway i figure out myself.

It is port configuration problem.

I change P3SEL |= 0x3f; → P3SEL |= 0x3e;

I think it is because Port 3.0 - 3.3 of the chip are connecting to cc2500.

So when select the ports, we must be careful. But be frank i still dunt know the exact reason. :oops: :?:

Here is my complete code(working):

int aNumber=12;

linkTo()

{

P3SEL = 0x3e; // If i put this one here, transmission will fail

BCSCTL1 = CALBC1_1MHZ; // Set DCO = 1MHz

DCOCTL = CALDCO_1MHZ;

UCA0CTL1 |= UCSSEL_2; // SMCLK

UCA0BR0 = 0x68; // 1MHz 9600

UCA0BR1 = 0; // 1MHz 9600

UCA0MCTL = UCBRF_0 + UCBRS_1 ; // Modulation UCBRSx = 1

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

IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt

__enable_interrupt();

}

#pragma vector=USCIAB0RX_VECTOR

__interrupt void USCI0RX_ISR(void)

{

aNumber = UCA0RXBUF; // TX → RXed character

}

when there is no interrup, aNumber =12. When interrup happens, aNumber changes value. Nxt time the End-Device pwr on, the value is the same as the last time.