LPC2148 and HERCULES SETUP UTILITY

Hi! I tried to view my output ( using rprintf ) on the Hercules terminal by choosing the COM1 and the appropriate baud rate but after thousands of tries, I got only this kind of response :

Serial port COM1 opened

ÑÔ9ä11ëÔÃ())6Ô{FF}())6Ô{FF}())6Ô{FF}())6Ô{FF}()+4Ô{FF}(++4Ô{FF}(++4Ô{FF}(++4Ô{FF}(++4Ô{FF}(++4Ô{FF}(++4Ô{FF}(++4Ô

or

Serial port COM1 opened

ü´ùþ”ûþ–ùü´ùü´ùþ–ûü–ùü´ùþ”ûþ

Serial port COM1 closed

Any idea why I can’t view the good words ???

Looks like the baud rate isn’t correct (either it is programmed wrong or the processor clock is set up wrong).

/mike

Yes, I was thinking about the baud rate too, but

  • in my Makefile, it is 38400

  • when I initialise the serial port, I put 38400 as parameter

  • when I use HERCULES SETUP UTILITY I choose 38400

And I did the same manipulation with 9600 everywhere !!

Here is my code :

SERIAL.C

#include "LPC214x.h"
#include "target.h"
#include "serial.h"

#define CR     0x0D

/* Initialize Serial Interface UART0 */
void init_serial0 ( unsigned long baudrate )
{
    unsigned long Fdiv;

    PINSEL0 |= 0x00000005;                  /* Enable RxD0 and TxD0              */
    U0LCR = 0x83;                          /* 8 bits, no Parity, 1 Stop bit     */
    Fdiv = ( Fcclk / 16 ) / baudrate ;     /* baud rate                        */
	U0DLM = Fdiv / 256;
    U0DLL = Fdiv % 256;
    U0LCR = 0x03;                           /* DLAB = 0                         */
}

/* Write character to Serial Port 0 with \n -> \r\n  */
int putchar_serial0 (int ch)
{
    if (ch == '\n')
    {
        while (!(U0LSR & 0x20));
        U0THR = CR;                  /* output CR */
    }
    while (!(U0LSR & 0x20));
    return (U0THR = ch);
}

/* Write character to Serial Port 0 without \n -> \r\n  */
int putc_serial0 (int ch)
{
    while (!(U0LSR & 0x20));
    return (U0THR = ch);
}

And here is the function I am using :

void bootUp(void)
{
	//Init rprintf
	init_serial0(38400);				//Set up the baud rate
	
	//Initialize UART for RPRINTF
    rprintf_devopen(putc_serial0);

	//Initialize I/O Ports and Peripherals

	IODIR0 |= LED; ///P0.15 is set as an output
	
    //Setup the Interrupts
	//Enable Interrupts

	VPBDIV=1;	// Set PCLK equal to the System Clock	

	VICIntSelect = ~(INT_TIMER0|INT_UART0);

		VICVectCntl0 = 0x20 | 4;						//Timer 0 Interrupt
	VICVectAddr0 = (unsigned int)ISR_Timer0;
		VICVectCntl1 = (0x20 | 6);
	VICVectAddr1 = (unsigned int)ISR_UART0;					
}

So what about the processor clock ??

What about peripherals clock ? Baudrate is derived from it.

Angelo

Yes, i agree, but I don’t know what am I doing wrong…