MB2146-450-E Setup Guide
Chapter 4 Sample Code Manual
MCU-AN-500072-E-10 – Page
35
4.2.8 UART .c
In this function, the MCU works in an asynchronous mode, baud rate is
generated by
dedicated baud rate generator.
Following table describes the LCD library:
Function Name
Description
void UART_init (void)
Initializes UART module
void UART_sendbyte (char ch)
Send data ch by UART
__interrupt void UART_REC_INTER(void)
Received data by UART when data is arrived
Following table describes how to use these functions.
Example
Type
Operation
Return
Send data
UART_init();
UART_sendbyte(0x55);
Send out data 0x55 by UART
Receive data
UART_init();
Global variable PraGlo.Uart_Rec
saved the received data
4.2.9 delay_try Function
In this project some instruction need to be delayed, so the delay function must be defined
before using these C file. Following code is the delay_try function.
void delay_try(unsigned char Dat)
{
unsigned char i,j;
for(i=0;i<255;i++)
{
for(j=0;j<Dat;j++)
{
__wait_nop();
}
}
}