C Program to use the HC12 SCI

#include 

main()
{
    unsigned char c;

    SC0BDH = 0;
    SC0BDL = 52;   /* 9600 baud */

    SC0CR1 = 0x00; /* Normal mode, 8 bits,  no parity */

    SC0CR2 = 0x0C; /* Enable transmitter and receiver, no interrupts */

/*********************************************************************/
    To transmit data
/*********************************************************************/

    SC0DRL = 'h';  /* Send the letter h */
    while ((SC0SR1 & 0x80) == 0) ;   /* Wait for TDRE */

    SC0DRL = 'e';  /* Send the letter e */
    while ((SC0SR1 & 0x80) == 0) ;   /* Wait for TDRE */

/*********************************************************************/
    To receive data
/*********************************************************************/

    while ((SCOSR1 & 0x20) == 0) ;   /* Wait for received character */
    c = SC0DRL;

    if ((SC0SR1 & 0x0f) != 0)
    {
        Code to take care of error
    }
}