SSP

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SSP

930 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jdurand on Mon Sep 17 14:55:42 MST 2012
I'm using an LPC1226 and have ported SSP code over from a 1754 part where I have it talking to the same SPI part (a FLASH) with no problem.  I double-checked that I update the register names correctly, but maybe I missed something?

What I'm seeing here is when I send data, wait for the response, and then read the DR it always reads zero.  I checked the pins with a logic analyzer and the part is responding properly with non-zero data.

I slowed the clock down to less than 1MHz and while the part happily returned data, the DR is still zero.

Any ideas?

LPC_IOCON->PIO0_14 = 2; // SPI_CLK special function output
LPC_IOCON->PIO0_16 = 0b10010; // SPI_MISO special function input with pullup
LPC_IOCON->PIO0_17 = 2; // SPI_MOSI special function output

LPC_SYSCON->SYSAHBCLKCTRL |= 1<<11; // turn on clock
LPC_SYSCON->SSPCLKDIV = 1; // set SSP_PCLK to SystemCoreClock / 1 = 24MHz
LPC_SSP->CR0 =0x0007; // SPI mode 0,0, 8 bit data, Serial Clock Rate = SSP_PCLK / 1 = 24MHz
LPC_SSP->CPSR = 2; // SPI bit clock is SSP_PCLK / 2 = 12MHz (Flash can handle 33 in slow mode)
LPC_SSP->CR1 = 0b10; // enable SSP (should be last register written)


char SPI(char c) {  // send a byte and return the result

LPC_SSP->DR = c; // send byte to FIFO
while(!(LPC_SSP->SR & 4)); // wait until something in the receive FIFO
return (uint8_t)LPC_SSP->DR; // return the result
}
Labels (1)
0 Kudos
2 Replies

611 Views
rikje888
Contributor II

YES! Thank you!

I searched two days for this (although it being for a lpc11u24).

0 Kudos

611 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jdurand on Mon Sep 17 15:43:09 MST 2012
Found it!

Reserved bit 7 MUST be high on this pin.  Apparently the pin hardware on the chip has an analog mode even though this pin has no analog functions.

0 Kudos