UART Library

The UART hardware module is available with a number of ARM MCUs. The mikroC PRO for ARM UART Library provides comfortable work with the Asynchronous (full duplex) mode.

  Important :

Library Routines

Generic Routines

UARTx_Init

Prototype

void UARTx_Init(unsigned long baud_rate);

Description

Configures and initializes the UART module.

The internal UART module module is set to :

  • default Tx and Rx pins.
  • 8-bit data, no parity.
  • 1 STOP bit.
Parameters
  • baud_rate: requested baud rate.
Returns

Nothing.

Requires

Routine requires the UART module.

Example
// Initialize hardware UART1 module and establish communication at 2400 bps
UART1_Init(2400);
Notes
  • Refer to the device data sheet for baud rates allowed for specific peripheral clock values.
  • UART library routines require you to specify the module you want to use. To select the desired UART module, simply change the letter x in the routine prototype for a number from 0 to 7.
  • Switching between the UART modules in the UART library is done by the UART_Set_Active function (UART modules have to be previously initialized).
  • Number of UART modules per MCU differs from chip to chip. Please, read the appropriate datasheet before utilizing this library.
  • UART modules are set on the following pins :

    Stellaris

    • UART0 :
      • PA0/PA1 (all Cortex M3 and M4 MCUs).
    • UART1 :
      • PB0/PB1 - all Cortex M4 MCUs and following Cortex M3 MCUs : LM3S1607, LM3S1627, LM3S3634, LM3S3739, LM3S3749, LM3S5632, LM3S5732 and LM3S5739.
      • PB4/PB5 - LM3S1626.
      • PC6/PC7 - LM3S3748.
      • PD2/PD3 - all other Cortex M3 MCUs not listed before.
    • UART2 :
      • PB4/E4 - LM3S1607 Cortex M3.
      • PD0/PD1 - LM3S3739, LM3S3749 and LM3S5739 Cortex M3.
      • PG0/PG1 - all other Cortex M3 MCUs not listed before.
      • PD4/PD5 - TM4C129x Cortex M4 family.
      • PD6/PD7 - TM4C123x Cortex M4 family.
    • UART3 :
      • PJ0/PJ1 - TM4C129x Cortex M4 family.
      • PC6/PC7 - TM4C123x Cortex M4 family.
    • UART4 :
      • PA2/PA3 - TM4C129x Cortex M4 family.
      • PC4/PC5 - TM4C123x Cortex M4 family.
    • UART5 :
      • PH6/PH7 - TM4C129x Cortex M4 family.
      • PE4/PE5 - TM4C123x Cortex M4 family.
    • UART6 :
      • PP0/PP1 - TM4C129x Cortex M4 family.
      • PD4/PD5 - TM4C123x Cortex M4 family.
    • UART7 :
      • PC4/PC5 - TM4C129x Cortex M4 family.
      • PE0/PE1 - TM4C123x Cortex M4 family.
    • The compiler will choose for which speed the calculation is to be performed (high or low). This does not mean that it is the best choice for desired baud rate.
      If the baud rate error generated in this way is too big then UARTx_Init_Advanced routine, which allows speed select, should be used.

    MSP432

    • UART0 :
      • PA2/PA3.
    • UART1 :
      • PA10/PA11.
    • UART2 :
      • PB2/PB3.
    • UART3 :
      • PE6/PE7.

    STM32

    • UART1 :
      • PA9/PA10 - all Cortex M0, M3 and M4 MCUs.
    • UART2 :
      • PA2/PA3 - all Cortex M0, M3 and M4 MCUs.
    • UART3 :
      • PB8/PB9 - STM32F373x/STM32F378x/STM32F383x Cortex M4 MCUs.
      • PC6/PC7 - STM32F401/411 Cortex M4 MCUs.
      • PB10/PB11 all Cortex M0, M3 and other Cortex M4 MCUs not listed before.
    • UART4 :
      • PA0/PA1 - all Cortex M0 MCUs.
      • PC10/PC11 - all Cortex M3 and Cortex M4 MCUs.
    • UART5 :
      • PC12/PD2 - all Cortex M3 and Cortex M4 MCUs.
    • UART6 :
      • PC6/PC7 - all Cortex M3 and Cortex M4 MCUs.
    • UART7 :
      • PE7/PE8 - all Cortex M4 MCUs.
    • UART8 :
      • PE0/PE1 - all Cortex M4 MCUs.

    CEC1302

    • UART1 :
      • GPIO162/GPIO165

    CEC1702

    • UART0 :
      • GPIO104/GPIO105
    • UART1 :
      • GPIO171/GPIO170

    Kinetis

    • UART0 :
      • PB16/PB17
    • UART1 :
      • PC4/PC3
    • UART2 :
      • PD3/PD2
    • UART3 :
      • PC16/PC17
    • UART4 :
      • PE24/PE25
    • UART5 :
      • PD9/PD8

UARTx_Init_Advanced

Prototype // for Stellaris MCUs :

void UARTx_Init_Advanced(unsigned long baud_rate, unsigned long freq_Khz, unsigned int data_bits, unsigned int parity, unsigned int stop_bits, unsigned int high_low);

// for Stellaris MCUs with alternative PORT functions on GPIO pins :

void UARTx_Init_Advanced(unsigned long baud_rate, unsigned long freq_Khz, unsigned int data_bits, unsigned int parity, unsigned int stop_bits, unsigned int high_low, const Module_Struct *module);

// for MSP432 MCUs :

void UARTx_Init_Advanced(unsigned long baudRate, unsigned int clockSource, unsigned int dataBits, unsigned int parity, unsigned int stopBits, unsigned int sbf, const module_Struct* module);

// for ST and Kinetis MCUs :

void UARTx_Init_Advanced(unsigned long baud_rate, unsigned int data_bits, unsigned int parity, unsigned int stop_bits, const module_Struct* module);

// for CEC1x02 MCU :

void UARTx_Init_Advanced(unsigned long baud_rate, unsigned int data_bits, unsigned int parity, unsigned int stop_bits);

Description

Configures and initializes the UART module with user defined settings.

Parameters

Stellaris

  • baud_rate: Requested baud rate.
  • freq_Khz: Peripheral Bus Clock frequency in kHz.
  • data_bits: Data bits selection parameter. Valid values :

    Data Bits
    Description Predefined library const
    5 data bits _UART_5_BIT_DATA
    6 data bits _UART_6_BIT_DATA
    7 data bits _UART_7_BIT_DATA
    8 data bits _UART_8_BIT_DATA
  • parity: Parity selection parameter. Valid values :

    Parity Mode
    Description Predefined library const
    No parity _UART_NOPARITY
    Even parity _UART_EVENPARITY
    Odd parity _UART_ODDPARITY
    Parity bit is one _UART_PARITY_ONE
    Parity bit is zero _UART_PARITY_ZERO
  • stop_bits: Stop bit selection parameter. Valid values :

    Stop bits
    Description Predefined library const
    One stop bit _UART_ONE_STOPBIT
    Two stop bit _UART_TWO_STOPBITS
  • high_low: High/low speed selection parameter. Valid values :

    High/Low Speed
    Description Predefined library const
    Low Speed UART _UART_LOW_SPEED
    Hi Speed UART _UART_HIGH_SPEED
  • module: appropriate module pinout. Use Code Assistant to list available module pinouts by typing _GPIO_MODULE_U and pressing Ctrl + Space.

MSP432

  • baudRate: Requested baud rate.
  • clockSource: clock source. Valid values :
    Clock source
    Description Predefined library const
    Externally provided clock _UART_CLOCK_SOURCE_UCLK
    Auxiliary clock _UART_CLOCK_SOURCE_ACLK
    Low-speed subsystem master clock _UART_CLOCK_SOURCE_SMCLK
  • dataBits: Data bits selection parameter. Valid values :

    Data Bits
    Description Predefined library const
    7 data bits _UART_7_BIT_DATA
    8 data bits _UART_8_BIT_DATA
  • parity: Parity selection parameter. Valid values :

    Parity Mode
    Description Predefined library const
    No parity _UART_NOPARITY
    Even parity _UART_EVENPARITY
    Odd parity _UART_ODDPARITY
    Enable parity _UART_ENABLEPARITY
  • stopBits: Stop bit selection parameter. Valid values :

    Stop bits
    Description Predefined library const
    One stop bit _UART_ONE_STOPBIT
    Two stop bit _UART_TWO_STOPBITS
  • sbf: most/least significant bit first. Valid values :

    Most/least significant bit first
    Description Predefined library const
    Most significant bit first _UART_MSB_FIRST
    Least significant bit first _UART_LSB_FIRST
  • module: appropriate module pinout. Use Code Assistant to list available module pinouts by typing _GPIO_MODULE_U and pressing Ctrl + Space.

STM32

  • baud_rate: Requested baud rate.
  • data_bits: Data bits selection parameter. Valid values :

    Data Bits
    Description Predefined library const
    8 data bits _UART_8_BIT_DATA
    9 data bits _UART_9_BIT_DATA
  • parity: Parity selection parameter. Valid values :

    Parity Mode
    Description Predefined library const
    No parity _UART_NOPARITY
    Even parity _UART_EVENPARITY
    Odd parity _UART_ODDPARITY
    Parity bit is one _UART_PARITY_ONE
    Parity bit is zero _UART_PARITY_ZERO
  • stop_bits: Stop bit selection parameter. Valid values :

    Stop bits
    Description Predefined library const
    Half stop bit _UART_HALF_STOPBIT
    One stop bit _UART_ONE_STOPBIT
    One and a half stop bits _UART_ONE_AND_A_HALF_STOPBITS
    Two stop bit _UART_TWO_STOPBITS
  • module: appropriate module pinout. Use Code Assistant to list available module pinouts by typing _GPIO_MODULE_U and pressing Ctrl + Space.

CEC1x02

  • baud_rate: Requested baud rate.
  • data_bits: Data bits selection parameter. Valid values :

    Data Bits
    Description Predefined library const
    5 data bits _UART_5_BIT_DATA
    6 data bits _UART_6_BIT_DATA
    7 data bits _UART_7_BIT_DATA
    8 data bits _UART_8_BIT_DATA
  • parity: Parity selection parameter. Valid values :

    Parity Mode
    Description Predefined library const
    No parity _UART_NOPARITY
    Even parity _UART_EVENPARITY
    Odd parity _UART_ODDPARITY
  • stop_bits: Stop bit selection parameter. Valid values :

    Stop bits
    Description Predefined library const
    One stop bit _UART_ONE_STOPBIT
    Two stop bit _UART_TWO_STOPBIT

Kinetis

  • baud_rate: Requested baud rate.
  • data_bits: Data bits selection parameter. Valid values :

    Data Bits
    Description Predefined library const
    8 data bits _UART_8_BIT_DATA
    9 data bits _UART_9_BIT_DATA
  • parity: Parity selection parameter. Valid values :

    Parity Mode
    Description Predefined library const
    No parity _UART_NOPARITY
    Even parity _UART_EVENPARITY
    Odd parity _UART_ODDPARITY
  • stop_bits: Stop bit selection parameter. Valid values :

    Stop bits
    Description Predefined library const
    One stop bit _UART_ONE_STOPBIT
    Two stop bit _UART_TWO_STOPBITS
  • module: appropriate module pinout. Use Code Assistant to list available module pinouts by typing _GPIO_MODULE_U and pressing Ctrl + Space.
Returns

Nothing.

Requires

Routine requires the UART module.

Example

Stellaris

// Initialize hardware UART1 module at 115200 bps with 10 MHz peripheral clock, 8 data, no parity and 1 stop bit in high speed mode :
UART1_Init_Advanced(115200, 10000, _UART_8_BIT_DATA, _UART_NOPARITY, _UART_ONE_STOPBIT, _UART_HIGH_SPEED);

// Initialize hardware UART1 module on GPIO_PORTA at 115200 bps with 10 MHz peripheral clock, 8 data, no parity and 1 stop bit in high speed mode :
UART1_Init_Advanced(115200, 10000, _UART_8_BIT_DATA, _UART_NOPARITY, _UART_ONE_STOPBIT, _UART_HIGH_SPEED, &_GPIO_MODULE_UART1_A01);

MSP432

// Initialize hardware UART1 module at 115200 bps, 8 data, no parity and 1 stop bit :
UART1_Init_Advanced(115200, _UART_CLOCK_SOURCE_SMCLK, _UART_8_BIT_DATA, _UART_8_BIT_DATA, _UART_ONE_STOPBIT, _UART_LSB_FIRST, _GPIO_MODULE_UARTA1_A1011);

STM32

// Initialize hardware UART1 module on PORTA at 115200 bps, 8 data, no parity and 1 stop bit :
UART1_Init_Advanced(115200, _UART_8_BIT_DATA, _UART_NOPARITY, _UART_ONE_STOPBIT, &_GPIO_MODULE_USART1_PA9_10);

CEC1x02

// Initialize hardware UART1 module at 115200 bps, 8 data, no parity and 1 stop bit :
UART1_Init_Advanced(115200, _UART_8_BIT_DATA, _UART_NOPARITY, _UART_ONE_STOPBIT);

Kinetis

// Initialize hardware UART1 module on PORTA at 115200 bps, 8 data, no parity and 1 stop bit :
UART1_Init_Advanced(115200, _UART_8_BIT_DATA, _UART_NOPARITY, _UART_ONE_STOPBIT, &_GPIO_Module_UART1_PC4_3);
Notes
  • Refer to the device data sheet for baud rates allowed for specific peripheral clock values.
  • UART library routines require you to specify the module you want to use. To select the desired UART module, simply change the letter x in the routine prototype for a number from 0 to 7.
  • Switching between the UART modules in the UART library is done by the UART_Set_Active function (UART modules have to be previously initialized).
  • Number of UART modules per MCU differs from chip to chip. Please, read the appropriate datasheet before utilizing this library.
  • For available working modes for a specific MCU please read the appropriate datasheet.

UARTx_Data_Ready

Prototype

unsigned UARTx_Data_Ready();

Description

The function tests if data in receive buffer is ready for reading.

Parameters

None.

Returns
  • 1 if data is ready for reading.
  • 0 if there is no data in the receive register.
Requires

Routine requires at least one UART module.

Used UART module must be initialized before using this routine. See UARTx_Init and UARTx_Init_Advanced routines.

Example
unsigned receive;
...
// read data if ready
if (UART1_Data_Ready())
  receive = UART1_Read();
Notes
  • UART library routines require you to specify the module you want to use. To select the desired UART module, simply change the letter x in the routine prototype for a number from 0 to 7.
  • Number of UART modules per MCU differs from chip to chip. Please, read the appropriate datasheet before utilizing this library.

UARTx_Tx_Idle

Prototype

char UARTx_Tx_Idle();

Description

Use the function to test if the transmit shift register is empty or not.

Parameters

None.

Returns
  • 1 if the data has been transmitted.
  • 0 otherwise.
Requires

Routine requires at least one UART module.

Used UART module must be initialized before using this routine. See UARTx_Init and UARTx_Init_Advanced routines.

Example
// If the previous data has been shifted out, send next data:
if (UART1_Tx_Idle() == 1) {
  UART1_Write(_data);
 }
Notes
  • UART library routines require you to specify the module you want to use. To select the desired UART module, simply change the letter x in the routine prototype for a number from 0 to 7.
  • Number of UART modules per MCU differs from chip to chip. Please, read the appropriate datasheet before utilizing this library.

UARTx_Read

Prototype

unsigned UARTx_Read();

Description

The function receives a byte via UART. Use the UARTx_Data_Ready function to test if data is ready first.

Parameters

None.

Returns

Received byte.

Requires

Routine requires at least one UART module.

Used UART module must be initialized before using this routine. See UARTx_Init and UARTx_Init_Advanced routines.

Example
unsigned receive;
...
// read data if ready
if (UART1_Data_Ready())
  receive = UART1_Read();
Notes
  • UART library routines require you to specify the module you want to use. To select the desired UART module, simply change the letter x in the routine prototype for a number from 0 to 7.
  • Number of UART modules per MCU differs from chip to chip. Please, read the appropriate datasheet before utilizing this library.

UARTx_Read_Text

Prototype

void UARTx_Read_Text(char *Output, char *Delimiter, char Attempts);

Description

Reads characters received via UART until the delimiter sequence is detected. The read sequence is stored in the parameter output; delimiter sequence is stored in the parameter delimiter.

This is a blocking call: the delimiter sequence is expected, otherwise the procedure exits (if the delimiter is not found).

Parameters
  • Output: received text.
  • Delimiter: sequence of characters that identifies the end of a received string.
  • Attempts: defines number of received characters in which Delimiter sequence is expected. If Attempts is set to 255, this routine will continuously try to detect the Delimiter sequence.
Returns

Nothing.

Requires

Routine requires at least one UART module.

Used UART module must be initialized before using this routine. See UARTx_Init and UARTx_Init_Advanced routines.

Example

Read text until the sequence “OK” is received, and send back what’s been received:

UART1_Init(4800);                         // initialize UART1 module
Delay_ms(100);

while (1) {
  if (UART1_Data_Ready() == 1) {          // if data is received 
    UART1_Read_Text(output, "OK", 10);    // reads text until 'OK' is found
    UART1_Write_Text(output);             // sends back text 
 }
}
Notes
  • UART library routines require you to specify the module you want to use. To select the desired UART module, simply change the letter x in the routine prototype for a number from 0 to 7.
  • Number of UART modules per MCU differs from chip to chip. Please, read the appropriate datasheet before utilizing this library.

UARTx_Write

Prototype

void UARTx_Write(unsigned _data);

Description

The function transmits a byte via the UART module.

Parameters
  • _data: data to be sent.
Returns

Nothing.

Requires

Routine requires at least one UART module.

Used UART module must be initialized before using this routine. See UARTx_Init and UARTx_Init_Advanced routines.

Example
unsigned data = 0x1E;
...
UART1_Write(data);
Notes
  • UART library routines require you to specify the module you want to use. To select the desired UART module, simply change the letter x in the routine prototype for a number from 0 to 7.
  • Number of UART modules per MCU differs from chip to chip. Please, read the appropriate datasheet before utilizing this library.

UARTx_Write_Text

Prototype

void UARTx_Write_Text(char * UART_text);

Description

Sends text via UART. Text should be zero terminated and is limited to 255 characters.

Parameters
  • UART_text: text to be sent.
Returns

Nothing.

Requires

Routine requires at least one UART module.

Used UART module must be initialized before using this routine. See UARTx_Init and UARTx_Init_Advanced routines.

Example

Read text until the sequence “OK” is received, and send back what’s been received:

UART1_Init(4800);                         // initialize UART1 module
Delay_ms(100);

while (1) {
  if (UART1_Data_Ready() == 1) {          // if data is received 
    UART1_Read_Text(output, "OK", 10);    // reads text until 'OK' is found
    UART1_Write_Text(output);             // sends back text 
 }
}
Notes
  • UART library routines require you to specify the module you want to use. To select the desired UART module, simply change the letter x in the routine prototype for a number from 0 to 7.
  • Number of UART modules per MCU differs from chip to chip. Please, read the appropriate datasheet before utilizing this library.

UART_Set_Active

Prototype

void UART_Set_Active(unsigned (*read_ptr)(), void (*write_ptr)(unsigned char _data), unsigned (*ready_ptr)(), unsigned (*tx_idle_ptr)());

Description

Sets active UART module which will be used by UARTx_Data_Ready, UARTx_Read and UARTx_Write routines.

Parameters

Parameters :

Returns

Nothing.

Requires

Routine is available only for MCUs with multiple UART modules.

Used UART module must be initialized before using this routine. See UARTx_Init and UARTx_Init_Advanced routines.

Example
UART1_Init(9600);                    // initialize UART1 module
UART2_Init(9600);                    // initialize UART2 module

RS485Master_Init();                  // initialize MCU as Master

UART_Set_Active(&UART1_Read, &UART1_Write, &UART1_Data_Ready, &UART1_Tx_Idle); // set UART1 active
RS485Master_Send(dat,1,160);        // send message through UART1

UART_Set_Active(&UART2_Read, &UART2_Write, &UART2_Data_Ready, &UART2_Tx_Idle); // set UART2 active
RS485Master_Send(dat,1,160);        // send through UART2
Notes

None.

UARTx_Enable

Prototype

void UARTx_Enable(unsigned long *UART_Base);

Description

This function enables desired UART module.

Parameters
  • UART_Base: desired UART module base address.
Returns

Nothing.

Requires

UART library routines require you to specify the module you want to use. To select the desired UART module, simply change the letter x in the routine prototype for a number from 0 to 7.

Example
// Enable UART1 module
UART1_Enable(&USART1_SR);
Notes

Routine is available only for ST MCUs.

UARTx_Disable

Prototype

void UARTx_Disable(unsigned long *UART_Base);

Description

This function disables desired UART module.

Parameters
  • UART_Base: desired UART module base address.
Returns

Nothing.

Requires

UART library routines require you to specify the module you want to use. To select the desired UART module, simply change the letter x in the routine prototype for a number from 0 to 7.

Example
// Disable UART1 module
UART1_Enable(&USART1_SR);
Notes

Routine is available only for ST MCUs.

UART_Data_Ready

Prototype

unsigned UART_Data_Ready();

Description

The function tests if data in receive buffer is ready for reading.

This is a generic routine which uses the active UART module previously activated by the UART_Set_Active routine.

Parameters

None.

Returns
  • 1 if data is ready for reading.
  • 0 if there is no data in the receive register.
Requires

Routine requires at least one UART module.

Used UART module must be initialized before using this routine. See UARTx_Init and UARTx_Init_Advanced routines.

Example
unsigned receive;
...
// read data if ready
if (UART_Data_Ready())
  receive = UART_Read();
Notes

None.

UART_Tx_Idle

Prototype

char UART_Tx_Idle();

Description

Use the function to test if the transmit shift register is empty or not.

This is a generic routine which uses the active UART module previously activated by the UART_Set_Active routine.

Parameters

None.

Returns
  • 1 if the data has been transmitted.
  • 0 otherwise.
Requires

Routine requires at least one UART module.

Used UART module must be initialized before using this routine. See UARTx_Init and UARTx_Init_Advanced routines.

Example
// If the previous data has been shifted out, send next data:
if (UART_Tx_Idle() == 1) {
  UART_Write(_data);
 }
Notes

None.

UART_Read

Prototype

unsigned UART_Read();

Description

The function receives a byte via UART. Use the UART_Data_Ready function to test if data is ready first.

This is a generic routine which uses the active UART module previously activated by the UART_Set_Active routine.

Parameters

None.

Returns

Received byte.

Requires

Routine requires at least one UART module.

Used UART module must be initialized before using this routine. See UARTx_Init and UARTx_Init_Advanced routines.

Example
unsigned receive;
...
// read data if ready
if (UART_Data_Ready())
  receive = UART_Read();
Notes

None.

UART_Read_Text

Prototype

void UART_Read_Text(char *Output, char *Delimiter, char Attempts);

Description

Reads characters received via UART until the delimiter sequence is detected. The read sequence is stored in the parameter output; delimiter sequence is stored in the parameter delimiter.

This is a blocking call: the delimiter sequence is expected, otherwise the procedure exits (if the delimiter is not found).

This is a generic routine which uses the active UART module previously activated by the UART_Set_Active routine.

Parameters
  • Output: received text.
  • Delimiter: sequence of characters that identifies the end of a received string.
  • Attempts: defines number of received characters in which Delimiter sequence is expected. If Attempts is set to 255, this routine will continuously try to detect the Delimiter sequence.
Returns

Nothing.

Requires

Routine requires at least one UART module.

Used UART module must be initialized before using this routine. See UARTx_Init and UARTx_Init_Advanced routines.

Example

Read text until the sequence “OK” is received, and send back what’s been received:


while (1) {
  if (UART_Data_Ready() == 1) {          // if data is received 
    UART_Read_Text(output, "OK", 10);    // reads text until 'OK' is found
    UART_Write_Text(output);             // sends back text 
 }
}
Notes

None.

UART_Write

Prototype

void UART_Write(unsigned _data);

Description

The function transmits a byte via the UART module.

This is a generic routine which uses the active UART module previously activated by the UART_Set_Active routine.

Parameters
  • _data: data to be sent.
Returns

Nothing.

Requires

Routine requires at least one UART module.

Used UART module must be initialized before using this routine. See UARTx_Init and UARTx_Init_Advanced routines.

Example
unsigned data = 0x1E;
...
UART_Write(data);
Notes

None.

UART_Write_Text

Prototype

void UART_Write_Text(char * UART_text);

Description

Sends text via UART. Text should be zero terminated and is limited to 255 characters.

This is a generic routine which uses the active UART module previously activated by the UART_Set_Active routine.

Parameters
  • UART_text: text to be sent.
Returns

Nothing.

Requires

Routine requires at least one UART module.

Used UART module must be initialized before using this routine. See UARTx_Init and UARTx_Init_Advanced routines.

Example

Read text until the sequence “OK” is received, and send back what’s been received:

while (1) {
  if (UART_Data_Ready() == 1) {          // if data is received 
    UART_Read_Text(output, "OK", 10);    // reads text until 'OK' is found
    UART_Write_Text(output);             // sends back text 
 }
}
Notes

None.

Copyright (c) 2002-2019 mikroElektronika. All rights reserved.
What do you think about this topic ? Send us feedback!
Want more examples and libraries? 
Find them on LibStock - A place for the code