lpcware

LPC11C14 SPI configuration

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by Detli on Thu Dec 19 07:58:14 MST 2013
Hello,

i have a problem with the spi unit and i hope there is someone who can help me! :-)

I like to read data from an ADC with 24 MHz.
I use the internal RC oszillator with the pll for 48 MHz.
So i adjust the spi registers, but whenn i measure the spi clock with an oscilloscop, i measure only 12 MHz Clock.
Maybe i have a fault in my code?

###################################################

From system_LPC11xx.c :

#define CLOCK_SETUP           1
#define SYSCLK_SETUP          1
#define SYSOSC_SETUP          1
#define SYSOSCCTRL_Val        0x00000000
#define WDTOSC_SETUP          0
#define WDTOSCCTRL_Val        0x00000000
#define SYSPLLCLKSEL_Val      0x00000000
#define SYSPLL_SETUP          1
#define SYSPLLCTRL_Val        0x00000023
#define MAINCLKSEL_Val        0x00000003
#define SYSAHBCLKDIV_Val      0x00000001
#define AHBCLKCTRL_Val        0b0011011111111111111
#define SSP0CLKDIV_Val        0x00000001
#define UARTCLKDIV_Val        0x00000001
#define SSP1CLKDIV_Val        0x00000001

####################################################

From my main.c :

//SPI0
LPC_SYSCON->PRESETCTRL|= 0x01;//Reset De-Assert SPI0
LPC_SYSCON->SSP0CLKDIV|= 0x01;//Clock Divider = 1

//MISO
LPC_GPIO0->DIR&= ~(1<<8);
LPC_IOCON->PIO0_8|= 0x01;
//MOSI
LPC_GPIO0->DIR|= (1<<9);
LPC_IOCON->PIO0_9|= 0x01;
//CLK
LPC_IOCON->SCK_LOC|= 0x02;
LPC_GPIO0->DIR|= (1<<6);
LPC_IOCON->PIO0_6 |= 0x02;
//CS
LPC_GPIO2->DIR|= (1<<8);
LPC_IOCON->PIO2_8|= 0x10;
LPC_GPIO2->DATA|= (1<<8);

//Serial Clock Rate = PCLK / ( CPSDVSR*(SCR+1) ) ; SCR=0 ; PCLK=48MHz ; CPSDVSR=2 ;
//LPC_SSP0->DR = Data Register to write
LPC_SSP0->CPSR|= 0x02;//CPSDVSR = 2
LPC_SSP0->CR0 = 0x00;
LPC_SSP0->CR0|= 0x18f;//16bit Transfer ; SPI Format ; CLK Low between Frames ; SCR = 1

uint8_t i;
for ( i = 0; i < 8; i++ )
{
     spi_data = LPC_SSP0->DR;    //Tab 210 clear the RxFIFO
}

NVIC_EnableIRQ(SSP0_IRQn);    //Tab 442
LPC_SSP0->CR1|= 0x02;//SPI Enable

#############################################################

Outcomes