Introduction; Uart0; Calculating Baud Rate - Philips AN10369 Application Note

Uart/spi/i2c code examples
Table of Contents

Advertisement

Philips Semiconductors

1. Introduction

This application note provides code samples, which will enable the user to get a jump-
start into using some of the serial communication interfaces of the LPC2000 family. In
this application note code samples are provided for UART0, SPI and I
detailed description on the peripheral please refer to the User manual of the respective
device.
The basic startup assembly code is only shown for the I
and SPI, the basic startup code should setup the stack pointer for the Supervisor mode,
which could be done using the LDR (Load Register) instruction.
The code was tested on a LPC2106 evaluation board, which uses a 10 MHz crystal
(system clock). The on-chip PLL has not been used for the sample code examples given
below. If the user uses the code for a different crystal setting then be sure to set the baud
rate/speed of the peripheral accordingly before running the example code. Speed
calculations equations are provided for each peripheral. All the code samples are
configured to run from SRAM and they were compiled using the ADS (ARM Development
Suite) v1.2 compiler.
Though the below code samples have been successfully tested on the LPC2106 it
should work fine on rest of the Philips LPC2000 family devices after some minor
modifications. Minor modifications could be setting the Stack pointer correctly (depending
upon the SRAM present on chip), using the correct header files etc. If the end user
wishes to run the code from the on-chip Flash then a signature is to be placed at 0x14
and the code has to be linked differently in addition to other changes.

2. UART0

The below code sample configures UART0 to interface to a Terminal program running on
a host machine (maybe Tera Term Or HyperTerminal) at a baud rate of 9600. The code
simply prints "Philips LPC" on the host machine terminal program forever since it is
included in a while (1) loop. VPB Divider value is at its reset settings and hence the
peripheral clock is one fourth of the system clock. The VPB clock would then be 2.5MHz.
Steps on calculating the divisor value are shown below.

2.1 Calculating Baud rate

Baud rate is calculated using the following formula:
Application note
LDR SP, =0x4..
Required baud rate= VPB clock/ (16 * Divisor value)
9600 = 2.5MHz /16 * x
x = 16.2
= 0x10(after discarding the decimal part)
Rev. 01 — 06 April 2005
Philips ARM LPC microcontroller family
2
2
C-bus peripheral. For UART0
© Koninklijke Philips Electronics N.V. 2005. All rights reserved.
AN10369
C-bus. For
3 of 17

Advertisement

Table of Contents
loading

Table of Contents