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.
Tool/software:
In the uart_echo demo,
while(ui32Count--)
{
//
// Write the next character to the UART.
//
MAP_UARTCharPutNonBlocking(UART0_BASE, *pui8Buffer++);
}
What is the significance of MAP_ at the beginning of a function name? And where is the definition for this full name?
Is there an example showing the logic for how to deal with the FIFO being full already when the function is called?
Thanks
Hi Mark,
This is explained in Peripheral Driver Library user's guide in section 34.3. Please refer to it for details. Basically, you use MAP_xyz and let the build process resolve when to use ROM_xyz or xyz. Using ROM_xyz can save you flash spaces because that API is stored in the ROM and the processor run it out of the ROM but not all APIs are supported in ROM. If ROM_xyz is not available then MAP_xyz will resolve to xyz during build time and eventually the API xyz is stored in flash.
Thank you very much. I appreciate that. Is there any more extensive demo code anywhere showing how to use UARTCharPutNonBlocking, or do I need to develop all my own logic? From what I can see, the simple uart_echo example does not handle the condition when the FIFO is full.
while(ui32Count--)
{
//
// Write the next character to the UART.
//
MAP_UARTCharPutNonBlocking(UART0_BASE, *pui8Buffer++);
}
Where is the above code coming from? I don't see it in the uart_echo example but rather the below code in the example. In the below example code, it checks to see if there is available spaces in the FIFO before writing a new character to it.
while(MAP_UARTCharsAvail(UART0_BASE))
{
//
// Read the next character from the UART and write it back to the UART.
//
MAP_UARTCharPutNonBlocking(UART0_BASE, MAP_UARTCharGetNonBlocking(UART0_BASE));
I guess I should have copied a little more so you could see where it was coming from. This is what I see, starting on Line 100:
//*****************************************************************************
//
// Send a string to the UART.
//
//*****************************************************************************
void
UARTSend(const uint8_t *pui8Buffer, uint32_t ui32Count)
{
//
// Loop while there are more characters to send.
//
while(ui32Count--)
{
//
// Write the next character to the UART.
//
MAP_UARTCharPutNonBlocking(UART0_BASE, *pui8Buffer++);
}
}
Starting on Line 87, I see what you posted:
//
// Loop while there are characters in the receive FIFO.
//
while(MAP_UARTCharsAvail(UART0_BASE))
{
//
// Read the next character from the UART and write it back to the UART.
//
MAP_UARTCharPutNonBlocking(UART0_BASE,
UARTCharGetNonBlocking(UART0_BASE));
}
So if I understand the above correctly, as long as there are characters to read, it gets them and then sends them out immediately.
But in my application I have a complete new message to send that is a response to the message received, not an echo of the message received. The program was previously set up to send the message and keep looping and waiting until it was completely sent before moving on to execute other parts of the program. I wanted to just start loading the buffer and then come back to it and keep loading, and then keep checking and eventually turn off the RS485 transmitter. This is what I did, and it seems to be working well:
// In this function we have successfully stopped looping and waiting for characters to be transmitted
if(characters_to_send_HB)
{
for( i = 0 ; i < 300; i++) // Fill FIFO buffer
{
if(must_resend_char_HB)
global_char_HB = character_to_resend_HB;
else
global_char_HB = get_from_output_buffer_HB();
if ( UARTCharPutNonBlocking(UartPort_HB, global_char_HB) == false ) // character did not go in FIFO, must try again
{
character_to_resend_HB = global_char_HB;
must_resend_char_HB = true;
break;
}
else
{
must_resend_char_HB = false;
}
if(out_wrptr_HB == out_rdptr_HB)
{
Host_1_HB_transmission_finished = true;
characters_to_send_HB = false;
break;
}
}
}
Starting on Line 87, I see what you posted:
//
// Loop while there are characters in the receive FIFO.
//
while(MAP_UARTCharsAvail(UART0_BASE))
{
//
// Read the next character from the UART and write it back to the UART.
//
MAP_UARTCharPutNonBlocking(UART0_BASE,
UARTCharGetNonBlocking(UART0_BASE));
}
This is the code to echo back what is received.
//*****************************************************************************
//
// Send a string to the UART.
//
//*****************************************************************************
void
UARTSend(const uint8_t *pui8Buffer, uint32_t ui32Count)
{
//
// Loop while there are more characters to send.
//
while(ui32Count--)
{
//
// Write the next character to the UART.
//
MAP_UARTCharPutNonBlocking(UART0_BASE, *pui8Buffer++);
}
}
UARTSend is the function to send any arbitrary length of characters to the UART. You can use this function to send whatever you want to send based on your application..