Spi; Speed Calculation; C Code - Philips AN10369 Application Note

Uart/spi/i2c code examples
Table of Contents

Advertisement

Philips Semiconductors

3. SPI

The following code sample configures the SPI as a master and transmits data bytes on
the MOSI pin. Output waveforms are captured on the oscilloscope and shown below.
Since no slave device is physically connected to the master, SSEL should be driven high
(does not apply to the LPC213x family). MISO is not being used in this example. Also the
VPB clock is set to system clock (10MHz) and SPI is run at maximum speed
(SPCCR=0x8). CPOL and CPHA both are set to 0.

3.1 Speed Calculation

3.2 C Code

/* Include header file depending upon part used */
#include"LPC2....h"
void Initialize(void);
/* Macro Definitions */
#define SPIF (1<<7)
#define DATA 0xC1
/************************* MAIN *************************/
int main()
Application note
Fig 2. Code output
Speed of SPI= VPB clock/ SPCCR value= 10MHz/8= 1.25 MHz.
Rev. 01 — 06 April 2005
Philips ARM LPC microcontroller family
© Koninklijke Philips Electronics N.V. 2005. All rights reserved.
AN10369
6 of 17

Advertisement

Table of Contents
loading

Table of Contents