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.

Uart Fifo interrupt



 how do I use the fifo correctelly?

I can count how many times the fifo interruption was called, but every 16bytes, the uart finishes the communication. The uart sends a \n character. 

In my case, Im using the uart0 to the terminal and the uart1 with the serial to usb board. 

It is really hard for me to figure out this alone. 

Thank you!

Thiago 

//********************************************************************

//-----------------------------VARIABLES------------------------------

//********************************************************************

volatile uint8_t input[] = "Teste";

volatile uint8_t output[256];

volatile uint32_t FIFOCount =0;

//********************************************************************

//------------------------FUNCTION PROTOTYPES-------------------------

//********************************************************************

void ConfigureUART0(void);

void ConfigureUART1(void);

void UART1IntHandler(void);

void UART0IntHandler(void);

void UART_Transmit(uint32_t ui32UARTBase, const uint8_t *pui8Buffer);

//********************************************************************

//-----------------------------INT MAIN-------------------------------

//********************************************************************

int main(void)

{

    //

    // Set the clocking to run at 20 MHz (200 MHz / 10) using the PLL.

//

    SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |SYSCTL_XTAL_16MHZ);

    // Configure the LED as an output and turn it on.

    //

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_3 | GPIO_PIN_2 | GPIO_PIN_1);

    //

    // Set up the serial console to use for displaying messages.

    //

    ConfigureUART0();

    //

//Initilize the Uart port to communicate with the XBee radio at port B0 and B1

//

    ConfigureUART1();

//

//Enable interrupts to the processor

//

IntMasterEnable();

//UART_Transmit(UART0_BASE, (uint8_t *)"\n 7E000F1001000000000000FFFFFFFE0000549F\0");

//UART_Transmit(UART1_BASE, (uint8_t *)"7E 00 141001000000000000FFFFFFFE000054686961676F97\0");

UART_Transmit(UART1_BASE, (uint8_t *)"7E00141001000000000000FFFFFFFE000054686961676F97\0");

  while(1)

    {

  UART_Transmit(UART1_BASE, (uint8_t *)"7E00141001000000000000FFFFFFFE000054686961676F97\0");

    while(UARTBusy(UART1_BASE));

  UART_Transmit(UART0_BASE, (uint8_t *)"7E00141001000000000000FFFFFFFE000054686961676F97\0");

    while(UARTBusy(UART0_BASE));

  SysCtlDelay(SysCtlClockGet() / 12);

     }

}

//*******************************************************************************

//-----------------------CONFIGURATION FUNCTIONS---------------------------------

//*******************************************************************************

//*****************************************************************************

//

// This function sets up UART0 to be used for a console to display information

// as the example is running.

//

//*****************************************************************************

void ConfigureUART0(void)

{

    //

    // Enable GPIO port A which is used for UART0 pins.

    //

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

    //

    // Enable UART0

    //

    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

    //

    // Configure GPIO Pins for UART1 mode.

    //

    GPIOPinConfigure(GPIO_PA0_U0RX);

    GPIOPinConfigure(GPIO_PA1_U0TX);

    GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

    //

    // Use the internal 16MHz oscillator as the UART clock source.

    // Initialize the UART for console I/O.

    //

    UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200,

        (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));

    UARTFIFOLevelSet(UART0_BASE, UART_FIFO_TX1_8, UART_FIFO_RX1_8); //Add

    UARTTxIntModeSet(UART0_BASE, UART_TXINT_MODE_FIFO);

    IntEnable(INT_UART0); //enable the UART interrupt

    UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT | UART_INT_TX); //only enable RX and TX interrupts

    UARTFIFOEnable(UART0_BASE);

}

//*****************************************************************************

// Configure the UART1 and pins PB0 - PB1

// This UART1 is used for the XBee Radio

//*****************************************************************************

void ConfigureUART1(void)

{

    //

    // Enable the GPIO Peripheral used by the UART1.

    //

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

    //

    // Enable UART1

    //

    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);

    //

    // Configure GPIO Pins for UART1 mode.

    //

    GPIOPinConfigure(GPIO_PB0_U1RX);

    GPIOPinConfigure(GPIO_PB1_U1TX);

    GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);

    //

    // Use the internal 16MHz oscillator as the UART clock source.

    // Initialize the UART for console I/O.

    //

    UARTConfigSetExpClk(UART1_BASE, SysCtlClockGet(), 115200,

        (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));

   // IntMasterEnable(); //enable processor interrupts

    IntEnable(INT_UART1); //enable the UART interrupt

    UARTIntEnable(UART1_BASE, UART_INT_RX | UART_INT_RT); //only enable RX and TX interrupts

}

//*******************************************************************************

//-----------------------INTERRUPTION FUNCTIONS----------------------------------

//*******************************************************************************

// to receive from uart1

void UART0IntHandler(void)

{

    uint32_t ui32Status, i;

    ui32Status = UARTIntStatus(UART0_BASE, true); //get interrupt status

    UARTIntClear(UART0_BASE, ui32Status); //clear the asserted interrupts

    if(ui32Status & UART_INT_TX) {

         FIFOCount++; //Add

      }

    // ui32Bytes = ui32UartMessage;

     i = 0;

     while(UARTCharsAvail(UART0_BASE)) //loop while there are chars

      {

        input[i++]= UARTCharGet(UART0_BASE);

      }

}

// to receive from uart1

void UART1IntHandler(void)

{

    uint32_t ui32Status, i;

    ui32Status = UARTIntStatus(UART1_BASE, true); //get interrupt status

    UARTIntClear(UART1_BASE, ui32Status); //clear the asserted interrupts

    i = 0;

    while(UARTCharsAvail(UART1_BASE)) //loop while there are chars

        {

    //output[i++]= UARTCharGet(UART1_BASE);

    UARTCharPut(UART0_BASE, UARTCharGet(UART1_BASE)); //echo character

        }

}

void UART_Transmit(uint32_t ui32UARTBase, const uint8_t *pui8Buffer)

{

    //

    // Loop while there are more characters to send.

    //

    while(*pui8Buffer != '\0')

    {

        //

        // Write the next character to the UART.

        //

        UARTCharPut(ui32UARTBase, *pui8Buffer++);

    }

}


how do I use the fifo correctelly?Based on your code, I wrote this one. 
I can count how many times the fifo interruption was called, but every 16bytes, the uart finishes the communication. 
In my case, Im using the uart0 to the terminal and the uart1 with the serial to usb board. 
It is really hard for me to figure out this alone. 
Thank you!
Thiago 

//********************************************************************//-----------------------------VARIABLES------------------------------//********************************************************************
volatile uint8_t input[] = "Teste";volatile uint8_t output[256];volatile uint32_t FIFOCount =0;//********************************************************************//------------------------FUNCTION PROTOTYPES-------------------------//********************************************************************void ConfigureUART0(void);void ConfigureUART1(void);void UART1IntHandler(void);void UART0IntHandler(void);void UART_Transmit(uint32_t ui32UARTBase, const uint8_t *pui8Buffer);

//********************************************************************//-----------------------------INT MAIN-------------------------------//********************************************************************int main(void){

    //    // Set the clocking to run at 20 MHz (200 MHz / 10) using the PLL. //    SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |SYSCTL_XTAL_16MHZ);
    // Configure the LED as an output and turn it on.    //    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_3 | GPIO_PIN_2 | GPIO_PIN_1);
    //    // Set up the serial console to use for displaying messages.    //    ConfigureUART0();
    // //Initilize the Uart port to communicate with the XBee radio at port B0 and B1 //    ConfigureUART1(); // //Enable interrupts to the processor // IntMasterEnable(); //UART_Transmit(UART0_BASE, (uint8_t *)"\n 7E000F1001000000000000FFFFFFFE0000549F\0"); //UART_Transmit(UART1_BASE, (uint8_t *)"7E 00 141001000000000000FFFFFFFE000054686961676F97\0"); UART_Transmit(UART1_BASE, (uint8_t *)"7E00141001000000000000FFFFFFFE000054686961676F97\0");
  while(1)    {  UART_Transmit(UART1_BASE, (uint8_t *)"7E00141001000000000000FFFFFFFE000054686961676F97\0");    while(UARTBusy(UART1_BASE));
  UART_Transmit(UART0_BASE, (uint8_t *)"7E00141001000000000000FFFFFFFE000054686961676F97\0");    while(UARTBusy(UART0_BASE));  SysCtlDelay(SysCtlClockGet() / 12);     }}
//*******************************************************************************//-----------------------CONFIGURATION FUNCTIONS---------------------------------//*******************************************************************************
//*****************************************************************************//// This function sets up UART0 to be used for a console to display information// as the example is running.////*****************************************************************************void ConfigureUART0(void){    //    // Enable GPIO port A which is used for UART0 pins.    //    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    //    // Enable UART0    //    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
    //    // Configure GPIO Pins for UART1 mode.    //    GPIOPinConfigure(GPIO_PA0_U0RX);    GPIOPinConfigure(GPIO_PA1_U0TX);    GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    //    // Use the internal 16MHz oscillator as the UART clock source.    // Initialize the UART for console I/O.    //    UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200,        (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));

    UARTFIFOLevelSet(UART0_BASE, UART_FIFO_TX1_8, UART_FIFO_RX1_8); //Add
    UARTTxIntModeSet(UART0_BASE, UART_TXINT_MODE_FIFO);
    IntEnable(INT_UART0); //enable the UART interrupt    UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT | UART_INT_TX); //only enable RX and TX interrupts    UARTFIFOEnable(UART0_BASE);}
//*****************************************************************************// Configure the UART1 and pins PB0 - PB1// This UART1 is used for the XBee Radio//*****************************************************************************void ConfigureUART1(void){    //    // Enable the GPIO Peripheral used by the UART1.    //    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    //    // Enable UART1    //    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
    //    // Configure GPIO Pins for UART1 mode.    //    GPIOPinConfigure(GPIO_PB0_U1RX);    GPIOPinConfigure(GPIO_PB1_U1TX);    GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    //    // Use the internal 16MHz oscillator as the UART clock source.    // Initialize the UART for console I/O.    //    UARTConfigSetExpClk(UART1_BASE, SysCtlClockGet(), 115200,        (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
   // IntMasterEnable(); //enable processor interrupts    IntEnable(INT_UART1); //enable the UART interrupt    UARTIntEnable(UART1_BASE, UART_INT_RX | UART_INT_RT); //only enable RX and TX interrupts
}


//*******************************************************************************//-----------------------INTERRUPTION FUNCTIONS----------------------------------//*******************************************************************************

// to receive from uart1void UART0IntHandler(void){    uint32_t ui32Status, i;
    ui32Status = UARTIntStatus(UART0_BASE, true); //get interrupt status
    UARTIntClear(UART0_BASE, ui32Status); //clear the asserted interrupts
    if(ui32Status & UART_INT_TX) {
         FIFOCount++; //Add
      }
    // ui32Bytes = ui32UartMessage;     i = 0;

     while(UARTCharsAvail(UART0_BASE)) //loop while there are chars      {        input[i++]= UARTCharGet(UART0_BASE);
      }}
// to receive from uart1void UART1IntHandler(void){    uint32_t ui32Status, i;
    ui32Status = UARTIntStatus(UART1_BASE, true); //get interrupt status
    UARTIntClear(UART1_BASE, ui32Status); //clear the asserted interrupts    i = 0;
    while(UARTCharsAvail(UART1_BASE)) //loop while there are chars        {    //output[i++]= UARTCharGet(UART1_BASE);    UARTCharPut(UART0_BASE, UARTCharGet(UART1_BASE)); //echo character

        }}
void UART_Transmit(uint32_t ui32UARTBase, const uint8_t *pui8Buffer){    //    // Loop while there are more characters to send.    //    while(*pui8Buffer != '\0')    {        //        // Write the next character to the UART.        //        UARTCharPut(ui32UARTBase, *pui8Buffer++);    }}

  • Hello Thiago,

    What do you get on the console? Rather than using the hex values, can you try sending known characters.

    Regards
    Amit
  • Amit, I'm working with xbee radios.
    I need to send over uart tx the xbee string.
    For exemple,

    To transmit data wirelessly, i need to create a string with:
    Start bit: 7E
    Length: 00 14
    Farme type: 10
    Name id: 01
    Address: 00 00 00 00 FF FF (broadcast address)
    Reserved: FF FE
    Broadcast 00
    Options 00
    Transmit data "thiago" 54 68 69 61 67 6F
    Check sum 97

    The complete string looks like:

    7E0014100100000000FFFFFE000054686961676F97

    Here is my problem.

    When I transmit using the uart0 or uart1, it breaks the line every 16 bytes, like this:
    7E 00 14 10 01 00 00 00
    00 00 00 FF FF FF FE 00
    00 54 68 69 61 67 6F 97

    This makes my xbee not accept the transmission packet.

    I understand I could transmit normal characters, I just started working with the xbee payloads.

    Thank you for answering!
  • Hello Thiago

    This is a 8 byte break and not 16 byte.

    7E 00 14 10 01 00 00 00
    00 00 00 FF FF FF FE 00
    00 54 68 69 61 67 6F 97

    UART is asynchronous, so there would not be a continuous packet but a bit break in between any 2 bytes. Did you check with a LA as to what the byte break means for the Xbee radio?

    Regards
    Amit
  • Amit, thank you for your answer.

    I agree with you. The uart is a asynchronous protocol. The break between two bytes doesn't break the communication between the xbee and the stellaris board. Regardless working with xbee payload, let me put in another words.

    Lets say for example, I want send this string "Texas Instruments and Stellaris are great" between two microcontrollers using uart1 to tx and to rx.

    Right now, regardless seding the full string, my code is sending packets of 16 characters (bytes):

    T e x a s I n st r u m e n t s a
    0 1 2 3 4 5 6 7 8 9 10 11 12 13 1415 -> bytes sent

    n d S t e l l a r i s a r e g r e
    0 1 2 3 4 5 6 7 8 9 10 11 12 13 1415 -> bytes sent


    Accordinly with the stellaris manual, page 869, it seems to be correct:

    1) -> Data transmitted is stored in 16-byte FIFOs
    2) -> For transmission, data is written into the transmit FIFO.
    3) -> Data continues to be transmitted until there is no data left in the transmit FIFO.

    The point is, I need to setup the interrupt routine to fill the fifo before there is no data left in the TX Fifo.

    If I could do this, my output would be:

    T e x a s I n s t r u m e n t s a n d S t e l l a r i s a r e g r e a t
    0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 -> bytes sent
    | |
    Re-Fill Fifo Re-Fill Fifo


    I heard this is called circular buffer, but I dont know how to implement it on CCS.
    I saw other option using uDMA and ping pong buffers, but I'm not sure how to use it.

    Thank you Amit for your time, knowledge and attention.

    Thiago
  • Hello Thiago,

    The UARTCharPut polls on the UART TX FIFO full flag. So if there is a space in the FIFO it must write the next byte, making the FIFO to always full condition. However it does not seem that it is working that way for you. I would suggest checking it on a LA to see how the transmission is happening to the XBee module.

    For the DMA there is an example of udma_demo, which uses Software for TX and Ping Pong mechanism for RX in the TivaWare examples.

    Regards
    Amit
  • Thiago Borba Onofre said:

    When I transmit using the uart0 or uart1, it breaks the line every 16 bytes, like this:
    7E 00 14 10 01 00 00 00
    00 00 00 FF FF FF FE 00
    00 54 68 69 61 67 6F 97

    This makes my xbee not accept the transmission packet.

    Define "breaks the line"

    Robert

  • Hi Robert,

    Breaks the line it is a visual way to say the communication was stoped and it stated again.

    In other words, regardless transmitting the full string, the uart is transmitting 16 bytes, and them it stops go to the next line, transmits 16 more bytes. It is doing this over and over.

    As I described above, imagine you have a string "Texas Instruments and Stellaris are great". If I want to exchange it between two microcontrollers using uart1 to tx and to rx.

    Right now, regardless seding the full string, my code is sending packets of 16 characters (bytes):

    T e x a s I n st r u m e n t s a
    0 1 2 3 4 5 6 7 8 9 10 11 12 13 1415 -> bytes sent

    n d S t e l l a r i s a r e g r e
    0 1 2 3 4 5 6 7 8 9 10 11 12 13 1415 -> bytes sent

    I do have a problem with this. I want to send the full string without being interrupted:
    "Texas Instruments and Stellaris are great"

    I a practical world, my xbee radios dont understand half sentences.

    Thank you for your attention, your time, and for sharing your knowledge.

    Thiago
  • Hello Amit,

    I've been going through all texas instrumetns examples. They are very very useful and powerful. I'm proud for selecting TI to be working with. They also have this great forum with good people, like you and the others are always ready to help.
    Once more, thank you for you answer.

    It is true. I have a problem with the fifo full condition. Let's say that the XBee radios are a secondary problem here. The major problem is the filling the transmitt fifo buffer.

    Do you know if CCS has a built in fifo library to be used?

    Excluse-me, what do you mean with "checking it on a LA"?

    Thank you!

    Thiago
  • OK, how long is that pause? And how is it measured?

    Also it's time to use the favourite principle of one of our denizens, KISS.

    Create a program that only transmits a string continuously. Look for the gaps in that.

    And by LA Amit is referring to a Logic Analyzer. You should be able to trigger by gap size on a LA or a decent modern DSO.

    Robert

    BTW, I would be surprised if this is your XBee problem
  • Robert, thank you for your answer.

    Thank you for clarifing the LA.

    My code, right now is written to transmit a string continuously.

    I'm using this routine:

    void UART_Transmit(uint32_t ui32UARTBase, const uint8_t *pui8Buffer)
    {
    //
    // Loop while there are more characters to send.
    //
    while(*pui8Buffer != '\0')
    {
    //
    // Write the next character to the UART.
    //
    UARTCharPut(ui32UARTBase, *pui8Buffer++);
    }
    }


    I quite understand what I'm doing wrong.

    I have my string and I have my Uart TX Fifo.

    I need a buffer between passingi the string and sending data through the uart port.


    Do you have a kind of solid example of how doing this?

    I could'nt find any between texas examples and I really don't know how to go through this problem.

    Professor Valvano developed, in his website, a code for FIFO, but it was wrote for keil. It doesn't work for ccs. users.ece.utexas.edu/.../fifo.htm

    I'm sorry for my ignorance and insistence, but it has been painfull and frustrating the fact of not knowking how to design and implement this simple buffer to feed the uart tx.

    Thank you again for your help and your time.
  • Thiago Borba Onofre said:
    I'm using this routine:

    void UART_Transmit(uint32_t ui32UARTBase, const uint8_t *pui8Buffer)
    {
    //
    // Loop while there are more characters to send.
    //
    while(*pui8Buffer != '\0')
    {
    //
    // Write the next character to the UART.
    //
    UARTCharPut(ui32UARTBase, *pui8Buffer++);
    }
    }

    Are you getting gaps with this? There is no reason to expect so. If so how large are they?

    Thiago Borba Onofre said:
    I quite understand what I'm doing wrong.

    I have my string and I have my Uart TX Fifo.

    I need a buffer between passingi the string and sending data through the uart port.

    I don't think you've established that yet, you certainly haven't presented any reason to believe you have a buffering problem.

    You appear to be jumping to a fix before you've determined what the problem is.

    Robert

  • Robert Adsett72 said:
    you certainly haven't presented any reason to believe you have a buffering problem.

    And no reason to suspect that if such a problem exists that it would cause a communication problem. At the very least you need an indication of how large that gap is.

    Robert

  • Thank you Robert for your answer, but I dont think I had expressed myself clear enough.

    Everything is working fine. I agree with you. You are write. There is no communication problem.
    Even though, because everything Im doing is based on texas instruments examples.

    I just want to send more than 16bytes througth the uart port.

    I do have several programming skills limitations, I know.

    Sincerely, I don't know how to configure the uart peripheral to send more than 16 bytes per communication cycle.
    I know that I need to use the uart fifo interrupts, but I don't know how to configure and use them.
    I also don't know how to create the software fifo buffer to receive my strings and to send it to the uart fifo.

    Any type of help is Welcome!

    By the way, thank you for your attention, time and patience.

    Thiago
  • I don't understand, you code already sends more than 16 bytes in a communication cycle through the UART.

    Thiago Borba Onofre said:
    I know that I need to use the uart fifo interrupts, but I don't know how to configure and use them.

    No you do not.  In fact you are better off avoiding transmit interrupts until you need them.  You do not need a transmit interrupt to send more than 16 bytes. The simple loop on put char will do that with no problem. A problem with the simple put loop is a sign of something else wrong.  It is not a sign that you need a transmit interrupt, at least not usually. This is why I keep asking and will ask again,

    Are you see gaps in the transmit?

    If so how large are the gaps?

    How did you measure the gaps?

    Robert

  • Thiago Borba Onofre said:
    I know that I need to use the uart fifo interrupts, but I don't know how to configure and use them.

    Or to put it another way, you are claiming you need to know how to use transmit interrupts to solve your problem. I'm suggesting strongly that you have not found the problem yet.  It's too soon to implement a solution.

    Robert

  • As "one" of the (many) KISS proponents here - would it not prove useful for poster to (temporarily) transfer data between his MCU and his PC? (PC set to proper, mating, terminal mode)

    Does not the (other "x-bee") device "cloud" the playing field (poster Robert's suggested such - I agree).   Most here are unlikely to have poster's (special) device - we all have a PC.

    Poster may require a proper, "UART to USB" converter to connect between the PC and MCU's (non-ICDI) UART.

    Robert - properly & repeatedly - requests (some) measurement of poster's claim of signal "gap."   Perhaps the simple, "march of UART transmitted characters" across the PC screen, (i.e. the missing, diagnostic link) will (better) aid in that "gap detection."   (all other (undefined) methods of gap measure have been ignored and/or unimplemented by poster...)

  • I would worry that a PC terminal program might give an indication of delay when there is none present.

    There might be delays introduced by the serial/ USB converter, the bytes might be sent across USB in packets with a delay between them or the terminal program itself may appear to introduce a delay.

    There's also the possibility of perceptual artifacts.

    Robert
  • Yes - outside of logic analyzer and/or scope - all you've listed are possible.

    That said - via LX4F MCU I was able to transmit (visually) uninterrupted - line after line - of printable ASCII @ 19.2Kbaud - received via putty.

    No such 16 char "gap" was noted - which confirmed your (earlier & repeated) expectation...
  • First, I would like to say thank you for all of you who answered my post.

    At the very beggining it was really hard for me understand what was going on.
    I was overcomplicating.

    Robert, I'm sorry, you were right since the beggining. There wasn't problems with the code.
    I used the LA, and figure out the code was working fine.

    I could see only 16 bytes due some configurations on the terminal serial which Im using.
    You all oppened my eyes to see that the solution was in front of me.

    I went farther.
    I started analysing with my xbee radios were not answering.
    Then, I add a routine to convert char to hex before I send the data to the uart terminal.
    I still needing to treat the data that comes from the radios through the uart terminal.
    I would like to share this final code, that it may serve has a guide to someonelse.

    I do need more help with the xbee library, but I will maybe open a new topic.
    Every help is welcome.

    Thank you for your time and patience.

    Thiago



    #include <stdint.h>
    #include <stdbool.h>
    #include <string.h>
    #include "inc/hw_ints.h"
    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "driverlib/debug.h"
    #include "driverlib/fpu.h"
    #include "driverlib/adc.h"
    #include "driverlib/gpio.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/rom.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/systick.h"
    #include "driverlib/timer.h"
    #include "driverlib/uart.h"
    #include "project0.h"


    //********************************************************************
    //-----------------------------VARIABLES------------------------------
    //********************************************************************

    uint8_t txPacket[] = {"7E00141001000000000000FFFFFFFE000054686961676F97"};
    uint8_t nd[] = {"7E000408016E6424"};
    uint8_t output[25];
    //********************************************************************
    //------------------------FUNCTION PROTOTYPES-------------------------
    //********************************************************************
    void ConfigureUART0(void);
    void ConfigureUART1(void);
    void UART1IntHandler(void);
    void UART0IntHandler(void);
    void UARTSend(uint32_t ui32UARTBase, uint8_t *pui8Buffer, uint32_t ui32Count);
    uint8_t* hex_decode(uint8_t *in, size_t len, uint8_t *out)


    //********************************************************************
    //-----------------------------INT MAIN-------------------------------
    //********************************************************************
    int main(void)
    {


    //
    // Set the clocking to run at 20 MHz (200 MHz / 10) using the PLL.
    //
    SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |SYSCTL_XTAL_16MHZ);

    // Configure the LED as an output and turn it on.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_3 | GPIO_PIN_2 | GPIO_PIN_1);

    //
    // Set up the serial console to use for displaying messages.
    //
    ConfigureUART0();

    //
    //Initilize the Uart port to communicate with the XBee radio at port B0 and B1
    //
    ConfigureUART1();
    //
    //Enable interrupts to the processor
    //
    IntMasterEnable();

    hex_decode(txPacket, sizeof(txPacket)-1,output);
    UARTSend(UART1_BASE, output,25);

    hex_decode(nd, sizeof(nd)-1,output);
    UARTSend(UART1_BASE, output,25);

    while(1)
    {

    }
    }

    //*******************************************************************************
    //-----------------------CONFIGURATION FUNCTIONS---------------------------------
    //*******************************************************************************

    //*****************************************************************************
    //
    // This function sets up UART0 to be used for a console to display information
    // as the example is running.
    //
    //*****************************************************************************
    void ConfigureUART0(void)
    {
    //
    // Enable GPIO port A which is used for UART0 pins.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

    //
    // Enable UART0
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

    //
    // Configure GPIO Pins for UART1 mode.
    //
    GPIOPinConfigure(GPIO_PA0_U0RX);
    GPIOPinConfigure(GPIO_PA1_U0TX);
    GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

    //
    // Use the internal 16MHz oscillator as the UART clock source.
    // Initialize the UART for console I/O.
    //
    UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200,
    (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));


    UARTFIFOLevelSet(UART0_BASE, UART_FIFO_TX1_8, UART_FIFO_RX1_8); //Add

    UARTTxIntModeSet(UART0_BASE, UART_TXINT_MODE_FIFO);

    IntEnable(INT_UART0); //enable the UART interrupt
    UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT | UART_INT_TX); //only enable RX and TX interrupts
    UARTFIFOEnable(UART0_BASE);
    }

    //*****************************************************************************
    // Configure the UART1 and pins PB0 - PB1
    // This UART1 is used for the XBee Radio
    //*****************************************************************************
    void ConfigureUART1(void)
    {
    //
    // Enable the GPIO Peripheral used by the UART1.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

    //
    // Enable UART1
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);

    //
    // Configure GPIO Pins for UART1 mode.
    //
    GPIOPinConfigure(GPIO_PB0_U1RX);
    GPIOPinConfigure(GPIO_PB1_U1TX);
    GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);

    //
    // Use the internal 16MHz oscillator as the UART clock source.
    // Initialize the UART for console I/O.
    //
    UARTConfigSetExpClk(UART1_BASE, SysCtlClockGet(), 115200,
    (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));

    // IntMasterEnable(); //enable processor interrupts
    IntEnable(INT_UART1); //enable the UART interrupt
    UARTIntEnable(UART1_BASE, UART_INT_RX | UART_INT_RT); //only enable RX and TX interrupts

    }

    //*******************************************************************************
    //-----------------------INTERRUPTION FUNCTIONS----------------------------------
    //*******************************************************************************

    // to receive from uart1
    void UART0IntHandler(void)
    {
    uint32_t ui32Status;

    ui32Status = UARTIntStatus(UART0_BASE, true); //get interrupt status

    UARTIntClear(UART0_BASE, ui32Status); //clear the asserted interrupts

    while(UARTCharsAvail(UART0_BASE)) //loop while there are chars
    {
    UARTCharPut(UART1_BASE, UARTCharGet(UART0_BASE)); //echo character
    }
    }

    // to receive from uart1
    void UART1IntHandler(void)
    {
    uint32_t ui32Status;

    ui32Status = UARTIntStatus(UART1_BASE, true); //get interrupt status

    UARTIntClear(UART1_BASE, ui32Status); //clear the asserted interrupts
    i = 0;

    while(UARTCharsAvail(UART1_BASE)) //loop while there are chars
    {
    UARTCharPut(UART0_BASE, UARTCharGet(UART1_BASE)); //echo character
    }
    }

    void UARTSend(uint32_t ui32UARTBase, uint8_t *pui8Buffer, uint32_t ui32Count)
    {
    //
    // Loop while there are more characters to send.
    //
    while(ui32Count--)
    {
    //
    // Write the next character to the UART.
    //
    UARTCharPut(ui32UARTBase, *pui8Buffer++);
    }

    }


    //From: stackoverflow.com/.../convert-ascii-char-to-hexadecimal-char-in-c
    // accessed in april 10th 2016
    uint8_t* hex_decode(uint8_t *in, size_t len, uint8_t *out)
    {
    unsigned int i, t, hn, ln;

    for (t = 0,i = 0; i < len; i+=2,++t) {

    hn = in[i] > '9' ? (in[i]|32) - 'a' + 10 : in[i] - '0';
    ln = in[i+1] > '9' ? (in[i+1]|32) - 'a' + 10 : in[i+1] - '0';

    out[t] = (hn << 4 ) | ln;
    //printf("%s",out[t]);
    }
    return out;
    }
  • Glad we helped. It's very easy to get stuck seeing symptoms only one way. That's where an extra pair of eyes (and stubborn questions) can help.

    Robert