User:Pallerla

/********************************************************/ /*	FILE	:	CPU_uart.c 							*/ /*	VERSION	:	Ver 0.01 Rev 0.00						*/ /*	DATE	:	20-SEP-2006								*/ /*	AUTHOR	:	ELICO LTD								*/ /********************************************************/
 * 1) include"MPRCPU_header.h"

/********************************************************/ /*	LOCAL FUNCTIONS	DECLARATION							*/ /********************************************************/ static void uartInitialize(void);

/********************************************************/ /*	FUNCTION NAME	: uartInitialize					*/ /*	PURPOSE			: Initialize the UART - 1 channel 	*/ /* for 9600, 8 bits, 1 stop bit, none parity LSB first */ /********************************************************/			static void uartInitialize(void) {	int L_uc_dummy; /*cst = 0; tcspr &= 0xF0; cst = 1; */ u1mr = 0x05U;	// DATA-FORMAT = 8-BITS, INTERNAL CLOCK, 1 STOP-BIT, POLARITY-DISBLED u1c0 = 0x10U;	// MAIN-CLOCK IS SOURCE FOR THE BAUDRATE-REG., LSB FIRST. u1brg = (CLOCK / (16 * BAUDRATE)) - 1; // Where 32000000 is the Clock Frequency

//CLEAR THE TRANSMIT AND RECEIVE BUFFER u1tb = 0x0000U; L_uc_dummy = u1rb;

//ASSIGN PORT PIN AS TXD / RXD ps0_7 = 1;//TXD	PIN ps0_6 = 0;		//	i.e SELECTING THE PIN FOR UART FUNCTION AS RXD pd6_6 = 0;// i/p port pd6_7 = 1;// o/p port

// Enable UART1 transmit te_u1c1 = 1; // Enable UART1 receive re_u1c1 = 1; }

/********************************************************/ /*	FUNCTION NAME	: SerialTextWrite   				*/ /*	PURPOSE			: Display the text on the serial 	*/ /* window of the PC                                    */ /********************************************************/	void SerialTextWrite(char *c_stringPointer) {	char j,i; /*******why these values only*******/ char buf[] = {0x0d, 0x0a, 0x00}; //This buffer is used to display the content in the next line. uartInitialize; while(*c_stringPointer) {		while(ti_u1c1 == 0); 		// puts it in the UART 1 transmit buffer u1tb = *c_stringPointer++; for(j=0;j< 0xff;j++); }	for(i = 0;i<=2;i++)		//The no. of values in the array are 3 thats why the loop is kept for i<=2. {		while(ti_u1c1 == 0); 		// puts it in the UART 1 transmit buffer u1tb = buf[i]; for(j=0;j< 0xff;j++);		//approx. delay 500micro seconds } }