| 
#define CR_INTEGER_PRINTF
#include "UART.h"
#include "PLL_CONFIG.h"
#include "PRINT.h"
char a[4];
void UART0_INIT(int baud_rate)
{
        unsigned int k;
        k = SET(baud_rate);
        PCONP |= 1<<3; //power to UART0
        PCLKSEL0 |= 0x40; //pclk = cclk
        PINSEL0 |=  0x00000050;
        U0IER |= (1<<1) | (1<<0);          //Enabling the TX and RX interrupts
        U0LCR = 0x83;
        U0DLM = (k/256);
        U0DLL = (k%256);
        U0LCR = 0x03;
        U0FCR |= (1<<6) | (1<<0);         //Setting the RX Trigger level to 4
}
void send_data(char a)
{
         while(!((U0LSR)&0x20));
         U0THR = a;
}
void get_data()
{
        while(U0IIR & 0x04) {                             //Checking if 'Trigger level reached' interrupt flag is set
              a[0]=U0RBR;                                    //Reading 1st RX Byte from U0RBR
              a[1]=U0RBR;                                    //Reading 2nd RX Byte from U0RBR
              a[2]=U0RBR;                                    //Reading 3rd RX Byte from U0RBR
              a[3]=U0RBR;                                    //Reading 4th RX Byte from U0RBR
              for(char i=0;i<4;i++) {
printf("\n\rChars u entered are %c",a);
              }
        }
}
int main(void)
{
PLL_Config(6,1,12);
UART0_INIT(9600);
while(1)
{
get_data();
delay(300);
}
} |