Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem in the USCI Receive Interrupt Operation

Status
Not open for further replies.

Luniks

Newbie level 3
Joined
Feb 26, 2010
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,296
Hi everybody !

I am writing a UART code to communicate between a MSP430-F2350 and my PC and I have a problem with the Receive Interrupt Operation. This is my code :

Code:
#include <msp430x23x0.h>

__interrupt void USCI0RX_ISR(void);

void main(void)
{
	unsigned char Tab[7] = {0x48,0x65,0x6C,0x6C,0x6F,0x20,0x21}; // ASCII code
	unsigned int i;
	
	WDTCTL = WDTPW + WDTHOLD;			// Stop WDT
	BCSCTL1 = CALBC1_1MHZ;				// Set DCO
	DCOCTL = CALDCO_1MHZ;
	P3DIR |= 0x40;						// Set P3.6 to output direction
	P3OUT |= 0x40;						// P3.6 to high level (disabled UHF)
	
	P3SEL |= 0x30;						// P3.4,5 = USCI_A0 TXD/RXD
	UCA0CTL1 |= UCSSEL_2;				// SMCLK
	UCA0BR0 = 0x68;						// 1MHz : 9600 Bauds
	UCA0BR1 = 0x00;
	UCA0MCTL = UCBRS0;					// Modulation UCBRSx = 1
	UCA0CTL1 &= ~UCSWRST;				// Initialize USCI state machine
	IE2 |= UCA0RXIE;					// Enable USCI_A0 RX interrupt
	
	for (i=0; i<7; i++)					//---- Sending Hello !
	{
		while (!(IFG2 & UCA0TXIFG));
		UCA0TXBUF = Tab[i];
	}

	__bis_SR_register(LPM0_bits + GIE); // Enter LPM0, interrupts enabled
}

#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{
	while (!(IFG2 & UCA0TXIFG));
	UCA0TXBUF = UCA0RXBUF;				// Sending the received character
}

When I send my ASCII array before to enter in LPM0 mode I receiced correctly the string "Hello !" on my PC with Hterm. But if I press a key .... no echo in Hterm !

Any ideas ? Thanks ...
 

HI

It is bad programming way to place a while loop inside your ISR routine

You can place a SWITCH or IF sentence

You also need to implement a ring buffer for avoid loosing data

All the best

Bobi

The microcontroller specialist
 

Hi,

Thanks for yours advices ... I take notes ^^.
Do you have any ideas why the program don't go in the interrupt procedure ?

Regards
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top