Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem with Lpc2148 Uart

Status
Not open for further replies.

mrhazard

Newbie level 2
Joined
Mar 6, 2009
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,290
lpc2148 uart

Hi guys, i'm trying to set up a small code to echo a char in hyperterminal but it doesnt seem to work... here is my code I hope you can help me

Code:
#include <LPC214X.H>
#define CR 0x0D
void Initialize(void); // Inicializacion de UART0
int putchar (int ch); // Escribe un carácter en la puerta serial
int getchar (void); // Lee un caracter en la puerta serial



/************************* MAIN *************************/
int main(void)
{
	Initialize();// Inicialización de la UART0
	while(1)
	{
	    	putchar(U0RBR); 
		 
	};
		
} 
	
int putchar (int ch) /* Write character to Serial Port */
{
if (ch == '\n') {
while (!(U0LSR & 0x20));
U0THR = CR; /* output CR */
}
while (!(U0LSR & 0x20));
return (U0THR = ch);
}
int getchar (void) /* Read character from Serial Port */
{
while (!(U0LSR & 0x01));
return (U0RBR);
}
/*************** System Initialization ***************/
void Initialize()
{
VPBDIV =0x00; 
/* Initialize Pin Select Block for Tx and Rx */
PINSEL0=0x5;
/* Enable FIFO's and reset them */
U0FCR=0x7;
/* Set DLAB and word length set to 8bits */
U0LCR=0x83;
/* Baud rate set to 9600 */
U0DLL=0x62;
U0DLM=0x0;
/* Clear DLAB */
U0LCR=0x3;
}
/*********************************************************/
 

Hi..

Your code is simulating properly...... To get outputs only when you press a key.. you have to enable interrupts and write an ISR__irq....

;)
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top