
#include "P89LPC952.h"
#include <stdio.h>

void UART_Init()
{
  P1M1 = 0xFE;                    	// Configure P1.0 (TxD) as Output (UART0)
  
  	// configure baud rate generator
  	BRGR0_0 = 0x70;
  	BRGR1_0 = 0x01;
  	BRGCON_0 = 0x03;
	S0CON = 0x52;	  	
}


  void uart1_init (void)
{
  // TxD = push-pull, RxD = input
  P4M1 &= ~0x04;
  P4M2 |= 0x04;
  P4M1 |= 0x08;
  P4M2 &= ~0x08;

  // configure baud rate generator
  BRGCON_1 = 0x00;
  BRG0_1 = 0x70;
  BRG1_1 = 0x01;
  BRGCON_1 = 0x03;

  S1CON = 0x50;
 
} // uart_init

void main(void)
{
	DIVM = 0x01;
	TRIM &= ~0x40;
	AUXR1 |= 0x80;

	P5M1 = 0x00;
	P5M2 = 0x00;
   	
	UART_Init();
	uart1_init();
  	EA = 1;
	 
	P5 = 0xFF;

	printf("Hello World\n");
	
	S1CON = S1CON & 0xFD;
	P5 = S1CON;
	S1BUF = 'A';
	while(!(S1CON & 0x02));

	printf("1\n");

	while(1);
}