Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Thread

SPI Problem,

SPI Problem,

2005-10-24 by yodathgreat

Hi All,

Who can send me some exemples for make the Init on SPI of the 
LPC2214.

SPI Master Mode.. (for SD Card).

Best regards
Yodathegreat

I use a example of http://www.ulrichradig.de/index.html

And I don't have Clock or Data on MOSI...

IO0DIR &=~(1<<SPI_DI);//Setzen von Pin MMC_DI auf Input
IO0DIR |= (1<<SPI_Clock);//Setzen von Pin MMC_Clock auf Output
IO0DIR |= (1<<SPI_DO);//Setzen von Pin MMC_DO auf Output
IO0DIR |= (1<<MMC_Chip_Select);//Setzen von Pin MMC_Chip_Select auf Output
IO0DIR |= (1<<SPI_SS);	//Setzt den Pin MMC_Chip_Select auf High Pegel
// setup SCK pin P04
PINSEL0 &= ~(3<<8);
PINSEL0 |= (1<<8);
	
// setup MISO pin P05
PINSEL0 &= ~(3<<10);
PINSEL0 |= (1<<10);
// setup MOSI pin P06
PINSEL0 &= ~(3<<12);
PINSEL0 |= (1<<12);
// setup SSEL pin P07      // WICHTIG: auch wenn es nicht benutzt wird...
PINSEL0 &= ~(3<<14);    // ansonsten läuft die ganze SPI nicht
PINSEL0 |= 1<<14;
//Aktiviren des SPI - Bus, Master, Clock = Active LOW
S0SPCCR = 8; // low speed
S0SPCR = (1<<MSTR)|(1<<CPOL); //Enable SPI, SPI in Master Mode	

    while (TRUE)
    {
        S0SPDR = 0xff;
	while(!(S0SPSR & (1<<SPIF)));
	Temp = S0SPDR;
    }

Re: SPI Problem,

2005-10-25 by rtstofer

--- In lpc2000@yahoogroups.com, "yodathgreat" 
<christophe.darnet@l...> wrote:
>
> Hi All,
> 
> Who can send me some exemples for make the Init on SPI of the 
> LPC2214.
> 
> SPI Master Mode.. (for SD Card).
> 
> Best regards
> Yodathegreat

The code below (abbreviated, somewhat) is for the LPC2106 and is 
copied from the app note.  It should work and it looks a lot like 
that German code.

spi.h
============

#define SPI_MSTR	(0x00000020)	// 1->spi operates as Master

// spi clock counter setting
// the maximum spi speed will be limited by the MP3 chip at 1/6 of 
the 24.576
// MHz crystal.
// Divider = (14.6456 MHz * 4) / (24.576 MHz / 6) = 14.4, call it 16
// NOTE: divider MUST be an even number and > 14.4
#define SPI_DIVIDER	(16)			// approx 3.7 MHz


spi.c
============


#include "lpc210x.h"
#include "spi.h"

void spiInit(void)
{
	PINSEL0  |= 0x00005500;		// set proper bits for SPI
	SPI_SPCR  = SPI_MSTR;		// set spi as a master
	SPI_SPCCR = SPI_DIVIDER;	// set for 500 kHz
}

void spiSendByte(unsigned char c)
{
	SPI_SPDR = c;
	while (!(SPI_SPSR & SPI_SPIF))
		;
}

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.