--- In lpc2000@yahoogroups.com, Srinivasa Reddy Mannem
<mannem_sri@y...> wrote:
> Hi,
>
> I am working LPC2106 target board.
>
> I am trying to write some data to hyper terminal using serial port
( UART 0 ).
>
> But i couldn't get that.
>
> The crystal frequency of the board what i am using is 10MHz. And i
set the baud rate as 9600.
>
> To trace that i have included some printf statements in between my
program.
>
> I am getting those printf messages without any fail.
>
> Then why i am not getting any charecter in hyper terminal window.
>
> Please go through the attached hello.c program and let me know
where i am doing mistake.
>
> Looking forward to hear from you.
>
> Regards,
> -Srinivas.
>
The source code :
*********************************************
#include <stdio.h>
#include "C:\DefectValidation\lpc210x.h"
typedef unsigned char uint8_t;
typedef unsigned int uint16_t;
#define FOSC 10000000 //10MHz.
#define PLL_M 4
#define VPBDIV_VAL 1
#define UART_BAUD(baud) (uint16_t)(((FOSC*PLL_M/VPBDIV_VAL) /
((baud) * 16.0)) + 0.5)
void delay(unsigned long int);
uint16_t i;
int main()
{
uint8_t temp;
uint16_t baud = 9600, baud_rate;
PLLCFG = 0x23;
PLLFEED = 0xAA;
PLLFEED = 0x55;
PLLCON = 0x01;
PLLFEED = 0xAA;
PLLFEED = 0x55;
while(!(PLLSTAT & 0x0400)) {}
PLLCON = 0x03;
PLLFEED = 0xAA;
PLLFEED = 0x55;
VPBDIV = 0x01;
PCONP = 0x08;
PINSEL0 = 0x00000005;
UART0_LCR = 0x83;
baud_rate = UART_BAUD(baud);
printf("%d\n",baud_rate); // it's giving 210 after
that above calculation.
UART0_DLL = (uint8_t)(baud_rate); //
set for baud low byte
UART0_DLM = (uint8_t)((baud_rate) >> 8); //
set for baud high byte
printf("%x\n",UART0_DLL);
printf("%x\n",UART0_DLM);
UART0_LCR = 0x03;
UART0_IER = 0x00; // disable
all interrupts
UART0_THR = 0x0; // clear
line status register
UART0_FCR = 0x01;
UART0_THR = 'A';
while(1)
{
printf("Hello World..\n");
printf("Welcome to LPC 2106 target board...\n");
UART0_THR = 'B';
delay(10000);
while((UART0_LSR & 0x60) == 0);
}
return 0;
}
void delay(unsigned long int count)
{
for(i=0;i<=count;i++)
{
}
}
**************************************
Regards,
-Srinivas.