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.

CCS/MSP430F4152: MSP430F4152

Part Number: MSP430F4152

Tool/software: Code Composer Studio

Hello,

I am stuck with a small issue,

I am not able to find the solution.

I am using MSP430F4152.

IN the micro controller, I am using rx interrupt ( i receive the data from PC to the micro controller),

then I use timer interrupt, 

by timer interrupt, i transmit the data to the PC from Micro controller.

My Program in : 

//unsigned int old;
char old;

#pragma vector=BASICTIMER_VECTOR
__interrupt void basic_timer_ISR(void)
{  
            putchar(old);
             LPM3_EXIT;
}

#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCIA0RX_ISR (void)
{
    old = UCA0RXBUF;                   
 //   putchar( old);
//    LPM3_EXIT;
}

int main(void)
{
    unsigned int i;

       WDTCTL = WDTPW | WDTHOLD;	// stop watchdog timer
	
//----------------------------------------------------------
	      FLL_CTL0 |= XCAP11PF;                     // Configure load caps

               BTCTL = (BTIP2+BTIP0);                    //2 msec
	       IE2 |= BTIE;

         
              LCD_init();
	      uart_init();

while(1)
	      {

	          LCD[0] = digit[1];

//*/================================================
        
	          __bis_SR_register(LPM3_bits+GIE);
	       }
//	return 0;
}


PROBLEM :
 I WANT TO RECEIVE 52 (any 2 digit value) ,
 FROM PC TO MICRO CONTROLLER , 
 AND SEND THE VALUE TO PC via TRANSMIT FUNCTION.
1) AFTER RECEIVING DATA, IF I TRANSMIT IN rx interrupt : THE ACTUAL VALUE IS TRANSMITTING (EX : 52),
2) BUT IF I RECEIVE DATA BY rx interrupt,  AND TRANSMIT BY USING TIMER INTERRUPT : ONLY ONE DIGIT IS TRANSMITTING ( EX : I RECEIVE 52, BUT TRANSMIT ONLY '2')
       ( THIS DO NOT HAPPEN IN SINGLE DIGIT VALUE : THE VALUE I RECEIVE.....IS TRANSMITTED EXACT VALUE)


i WANT TO USE BOTH "rx interrupt AND timer interrupts ".
( I have used "int" type also)

CAN YOU PLEASE TELL ME, HOW TO SOLVE IT.

THANKS ,

Srijit.

  • From your description, it sounds as though your PC is sending both bytes back-to-back, within the Basic Timer window (2ms, or maybe 6ms if ACLK failed over to VLOCLK). In this case, the second Rx byte would overwrite "old" before the first gets sent. Could this be what is happening?

    In the general case, you should probably have a circular buffer to deal with this. If you know your transactions are always 2 bytes, you might get away with a simpler mechanism.

  • Hi,

    Thank you very much for your reply.

    1 ) you said "Circular Buffer"  : can you please explain that, how to do that ?

    2) IF I want to take only 2 bytes..then also can you please tell me the logic(code ..if possible).

    regards,

    Srijit

  • I think Google will explain Circular Buffer (more properly "Circular Queue") better than I will.

**Attention** This is a public forum