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.

Issue with UART and Xbee

Other Parts Discussed in Thread: CONTROLSUITE

Hi all, I bought a TSM320F2062, i am interfacing with xbee by sci-a port. I'm using the example proposed by ControlSuite, called SCI_echoback. As you know Xbee has two modes, either AT or API.

First I modified the example, and I make my own "hello world" in AT mode with twice xbee (they are configured correctly). if i send a message, always in AT mode, transmission works fine, I can be able to receipt or send any command. But, in API mode, it's impossible. I can't send anything, except one time, it's works.

I suposse All registers, are correctly configured, because in AT mode works fine. I tried several uart speed (setting SCIxBAUD), with no difference. Also, sniffing SCia I can see the correct API frame, like 7E 00 05 08 01 50 31 04 71.

baud rate is 9600, no parity, 8bit word, no handshake and one stop bit.

some advice?

Best regards

Alejandro

  • Hello Alejandro,

    Do you use interrupt for your code?

    Can you send the code for the SCI setting and about how you send command and receive the data?

    Hope somebody can notice the problem on your SCI.

    Best regards,

    Maria

  • Hi Maria, 

    i'm not using interrupts (not yet), just make a for(;;) sending a continuos msg.

    To send, I modified the example mentioned above, sci_echoback

    
    

    for(;;) {

    msg_frame[0] = 0x7E; // 7E
    msg_frame[1] = 0x00;//\x00'
    msg_frame[2] = 0x05;//'\x05'
    msg_frame[3] = 0x08;//'\x08'
    msg_frame[4] = 0x01;//'\x01'
    msg_frame[5] = 0x50;//'\x50'
    msg_frame[6] = 0x31;//'\x31'
    msg_frame[7] = 0x04;//'\x05'
    msg_frame[8] = 0x71;//'\x70' checksum


    char j = 0;
             while (sizeof(msg_frame) != j) {
             scia_xmit(msg_frame[j]);
              j++;
    }

    void scia_xmit(int a)
    {
    while (SciaRegs.SCIFFTX.bit.TXFFST != 0) {}
    SciaRegs.SCITXBUF=a;

    }

    The question is: why in AT mode I can send whole commands and not in API mode?

    Best regards

  • Hello Alex,

    What is your SCIFFTX setting?

    How about if you remove line 'while (SciaRegs.SCIFFTX.bit.TXFFST != 0) {}' ?

    And what is the difference between your code above and AT code? Is the difference only the data?

    Best regards,

    Maria

  • removed line "while(sciaRegs.........." no difference. Yes, in AT data is ASCII characters and API are hex.

    it needed reset SCI before to send a message?

  • Hello,

    I think you don't need to reset the SCI.

    Seems that your transmit is fine if you can get 7E 00 05 08 01 50 31 04 71 (you said you sniffed the SCIA and got this result).

    What is the type of msg_frame? Is it unsigned char?

    What result do you expect in your application?

    Best regards,

    Maria

  • Hello again,

    How about you try the setting without FIFO?

    1. Setup GPIOs for SCIA
    2. Init SCIA (modify it based on your setting)
        SciaRegs.SCICCR.all =0x0007;   // 1 stop bit,  No loopback
                                       // No parity,8 char bits,
                                       // async mode, idle-line protocol
        SciaRegs.SCICTL1.all =0x0003;  // enable TX, RX, internal SCICLK,
                                       // Disable RX ERR, SLEEP, TXWAKE
        
        SciaRegs.SCICTL2.bit.TXINTENA = 1;
        SciaRegs.SCICTL2.bit.RXBKINTENA = 1; // actually you don't need this

        
        SciaRegs.SCIHBAUD    =0x0001;  // 9600 baud @LSPCLK = 20MHz (80 MHz SYSCLK).
            SciaRegs.SCILBAUD    =0x0003;


        SciaRegs.SCICTL1.all =0x0023;  // Relinquish SCI from Reset
    }

    4. in for loop:
    for(;;) {
        msg_frame[0] = 0x7E; // 7E  //the type of msg_frame is unsigned char
        msg_frame[1] = 0x00;//\x00'
        msg_frame[2] = 0x05;//'\x05'
        msg_frame[3] = 0x08;//'\x08'
        msg_frame[4] = 0x01;//'\x01'
        msg_frame[5] = 0x50;//'\x50'
        msg_frame[6] = 0x31;//'\x31'
        msg_frame[7] = 0x04;//'\x05'
        msg_frame[8] = 0x71;//'\x70' checksum

        unsigned char i;
        i = 0;

        
        for(i = 0; i < (sizeof(msg_frame)); i++)
        {
            SciaRegs.SCITXBUF = msg_frame[i];
        }

    }

    Let see whether this works.

    Best regards,

    Maria

  • Hi Maria, finally works fine, I guess is a issue with zigbee xbee module. by the way, I've seen the function UARTprintf(); but I can't use it. I tried add uartstdio.c and uartstdio.h but doesn't works. 

    how add the files correctly?

  • Hi Alex,

    Check these threads out:

    http://e2e.ti.com/support/microcontrollers/c2000/f/171/t/128230.aspx

    http://e2e.ti.com/support/microcontrollers/c2000/f/171/t/128230.aspx

    Regards,

    Gautam