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 simple problem,

Please help me to solve it.

I want to receive multiple data,

but I am not able to receive it.

I tried different data types also.

Can you please solve it.

My program is  : 

Char old;     //int old
int main(void) { WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer FLL_CTL0 |= XCAP11PF; // Configure load caps //-------------------------------------------- P1DIR |= BIT4; // P5.1 output CCTL0 = CCIE; // CCR0 interrupt enabled // CCR0 = 50000; // TACTL = TASSEL_2 + MC_2; // SMCLK, continuous mode working TACTL = TASSEL_1 + MC_2; //================================FUNCTION================================== LCD_init(); uart_init(); while(1) { LCD[0] = digit[2]; //========================================================================== old = getchar(); := MY PROBLEM IS HERE..I CAN NOT RECEIVE MULTIPLE(100) DATA ..ONLY SINGLE DATA ('1' : YOU CAN SEE IN SWITCH CONDITION) // putchar(old); switch(old) { case '1': // "100" TACTL = TASSEL_1 + MC_2; old1= '1'; putchar('A'); // CCR0 = 50000; //100ms CCR0 = 1638; ////// 1638=10hz __bis_SR_register(LPM0_bits + GIE); break; case '2': TACTL = TASSEL_1 + MC_2; old1= '2'; putchar('B'); CCR0 = 8000; ////500msec ////8000 ==2hz __bis_SR_register(LPM0_bits + GIE); break; case '3': TACTL = TASSEL_1 + MC_2; old1= '3'; putchar('B'); CCR0 = 32768; ////1000msec __bis_SR_register(LPM0_bits + GIE); break; case '4': TACTL = TASSEL_2 + MC_2; old1= '4'; putchar('B'); // CCR0 = 25000; ////2000msec __bis_SR_register(LPM0_bits + GIE); break; default: TACTL = TASSEL_2 + MC_0; break; } } // return 0; } IF I USE SINGLE VARIABLE ..IT IS OK.
MY REST OF THE THINGS ARE WORKING FINE , (INTERRUPTS, UART , LCD FUNCTION). I TRIES TO USE OTHER THINGS ALSO (TRY TO USE RING BUFFER) CAN YOU PLEASE HELP ME WITH THE SOLUTION .

CAN YOU PLEASE HELP ME.

IT IS URGENT.

REGARDS,

Srijit

  • Hi Srijit,

    I read your post as saying that you are not receiving multiple characters over UART. Is that correct? If so, can you also share the code for the interrupt handler for the UART Rx?

    This is a code example that might give you some idea of the usage: http://dev.ti.com/tirex/explore/node?node=AJJlcCxl2-X.IDr5z0pwvw__IOGqZri__LATEST

    Srinivas

  • HI Shivam,

    Thank you very much for your reply.

    I am getting  the data , and also can be able to send the data through Tx & rx.

    But I have different issue,

    1)

    I am receiving data ( by interrupt or with out interrupt), 

    and transmitting data (ex : 1234 ) by transmit function..it is transmitting.
    2)
    But I want to receive data ( by interrupt or with out interrupt),
    and want to transmit data by using timer interrupt.
    (if I receive ex : 1234, and transmit by using timer interrupt....it transmit only '4')
    can you help  me to solve that.
    (because my logic is  : receive the data....then in timer interrupt ..there will be a counter++......  when the counter will be equal to received data.....then the output part will execute......that is second step....FIRST I WANT TO SEND THE FULL DATA VIA TIMER INTERRUPT.
    can you give me solution please.
    [
    # In my program : i have not used the rx interrupt...only rx function.....want want to store the value in buffer...that is also not working 
    getchar () :

    char getchar()
    {
    while(!(IFG2&UCA0RXIFG));
    return UCA0RXBUF;
    }

    UART : 

    void uart_init()
    {

    P6SEL |= BIT5+BIT6; // P6.5,6 = USCI_A0 RXD/TXD
    UCA0CTL1 |= UCSWRST;
    UCA0CTL1 |= UCSSEL_1; //UCSSEL_2; //UCSSEL_1; // CLK = ACLK

    UCA0BR0 = 3; // 32k/9600 - 3.41
    UCA0BR1 = 0x00; //
    UCA0MCTL = 0x06;
    UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
    IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt

    }

    putchar() : 

    void putchar(unsigned char DATA)
    {
    while(!(IFG2&UCA0TXIFG));
    UCA0TXBUF = DATA;
    }

    ]

    regards,
    Srijit.
  • >              old = getchar();        
    getchar() is blocking, so maybe you need something as simple as:
    >           byte0 = getchar();      // First byte of pair
    >           byte1 = getchar();      // Second byte of pair
    Then in the timer ISR:
    >           putchar(byte0);      // First byte of pair
    >           putchar(byte1);      // Second byte of pair
    Make sure your timer period is at least 2ms (2 bytes at 9600bps) so it doesn't overrun.

     

     

**Attention** This is a public forum