Content originally posted in LPCWare by Dino on Wed May 23 09:02:46 MST 2012
Goodmorning.
I hope someone can help me to solve this problem with the SPI1. I am using the LPC-Link and LPC11U14. I set the SPI as master mode as described in the SSP_Init . In the main program I call the function SSP_Send(&Data_SSP,1 ) were Data_SSP = 0x0f.
With the probe of oscilloscope I see the 8 clock pulses but the not the SSEL1 and MISO pulses.
Many Thanks
Here there are the [B][SIZE=2]SSP_Init[/SIZE][/B] and the function [SIZE=2][B]SSP_Send [/B][SIZE=3]I am using[/SIZE][B]:[/B]
[/SIZE]
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][B]void[/B]
[/COLOR][/SIZE][/COLOR][/SIZE][LEFT][SIZE=2][COLOR=#000000][B]SSP_Init[/B]( [/COLOR][/SIZE][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][B]void[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] )[/COLOR][/SIZE]
[LEFT][SIZE=2][B]{[/B][/SIZE]
[SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032][B]uint8_t[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][B] i, Dummy = Dummy;[/B][/SIZE][/LEFT]
[LEFT][SIZE=2][B]LPC_SYSCON->[/B][/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0][B]PRESETCTRL[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][B] |= (0x1<<2);[/B][/SIZE]
[SIZE=2][B]LPC_SYSCON->[/B][/SIZE][B][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]SYSAHBCLKCTRL[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] |= (1<<18); [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]//clock SSP1[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][COLOR=#3f7f5f]
[/COLOR][/SIZE][SIZE=2][B]LPC_SYSCON->[/B][/LEFT]
[/LEFT]
[/SIZE][LEFT][B][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]SSP1CLKDIV[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = 0x02; [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* Divided by 2 */[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][COLOR=#3f7f5f]
[/COLOR][/SIZE]
[LEFT][SIZE=2][B]LPC_IOCON->[/B][/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0][B]PIO1_20[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][B] &= ~0x07;[/B][/SIZE]
[SIZE=2][B]LPC_IOCON->[/B][/SIZE][B][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]PIO1_20[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] |= 0x02; [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* SSP CLK */[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][COLOR=#3f7f5f][/LEFT]
[/COLOR][/SIZE]
[LEFT][SIZE=2][B]LPC_IOCON->[/B][/SIZE][B][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]PIO1_21[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] &= ~0x07; [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* SSP I/O [U]config[/U] */[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][COLOR=#3f7f5f]
[/COLOR][/SIZE][SIZE=2][B]LPC_IOCON->[/B][/LEFT]
[/LEFT]
[/SIZE][LEFT][B][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]PIO1_21[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] |= 0x02; [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* SSP MISO */[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][COLOR=#3f7f5f]
[/COLOR][/SIZE]
[LEFT][SIZE=2][B]LPC_IOCON->[/B][/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0][B]PIO1_22[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][B] &= ~0x07;[/B][/SIZE]
[SIZE=2][B]LPC_IOCON->[/B][/SIZE][B][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]PIO1_22[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] |= 0x02; [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* SSP MOSI */[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][COLOR=#3f7f5f][/LEFT]
[/COLOR][/SIZE]
[LEFT][SIZE=2][B]LPC_IOCON->[/B][/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0][B]PIO1_23[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][B] &= ~0x07;[/B][/SIZE]
[SIZE=2][B]LPC_IOCON->[/B][/SIZE][B][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]PIO1_23[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] |= 0x02; [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* SSEL1 */[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][COLOR=#3f7f5f][/LEFT]
[/COLOR][/SIZE]
[LEFT][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f][B]/* Set DSS data to 8-bit, Frame format SPI, CPOL = 0, CPHA = 0, and SCR is 12 */[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f5f]
[/COLOR][/SIZE][SIZE=2][B]LPC_SSP1->[/B][/LEFT]
[/LEFT]
[/SIZE][LEFT][B][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]CR0[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = 0x0B07; [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// clock = 1Mhz //[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][COLOR=#3f7f5f]
[/COLOR][/SIZE]
[LEFT][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f][B]/* SSPCPSR clock [U]prescale[/U] register, master mode, minimum divisor is 0x02 */[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f5f]
[/COLOR][/SIZE][SIZE=2][B]LPC_SSP1->[/B][/LEFT]
[/LEFT]
[/SIZE][LEFT][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0][B]CPSR[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][B] = 0x2;[/B][/SIZE]
[LEFT][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][B]for[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][B] ( i = 0; i < FIFOSIZE; i++ )[/B][/SIZE]
[SIZE=2][B]{[/B][/SIZE]
[SIZE=2][B]Dummy = LPC_SSP1->[/B][/SIZE][B][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]DR[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]; [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* clear the RxFIFO */[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][COLOR=#3f7f5f]
[/COLOR][/SIZE][SIZE=2][B]}[/B][/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f][B]/* Master mode */[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f5f]
[/COLOR][/SIZE][SIZE=2][B]LPC_SSP1->[/B][/LEFT]
[/LEFT]
[/SIZE][LEFT][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0][B]CR1[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][B] = SSPCR1_SSE;[/B][/SIZE]
[LEFT][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][B]return[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][B];[/B][/SIZE]
[SIZE=2][B]}[/B][/SIZE][/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][B]//***************************************[/B][/COLOR][/SIZE][/COLOR][/SIZE][/SIZE]
[LEFT][SIZE=2][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][B]void[/B][/LEFT]
[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][LEFT][SIZE=2][COLOR=#000000][B]SSP_Send[/B]( [/COLOR][/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint8_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] *buf, [/COLOR][/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] Length )[/COLOR][/SIZE]
[LEFT][SIZE=2][B]{[/B][/SIZE]
[SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032][B]uint32_t[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][B] i, SspStatus;[/B][/SIZE]
[SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032][B]uint8_t[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][B] Dummy = Dummy;[/B][/SIZE][/LEFT]
[LEFT][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][B]for[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][B] ( i = 0; i < Length; i++ )[/B][/SIZE]
[SIZE=2][B]{[/B][/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f][B]/* Move on only if NOT busy and TX FIFO not full. */[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f5f]
[/COLOR][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]while[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ( (LPC_SSP1->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]SR[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][B] & (SSPSR_TNF|SSPSR_BSY)) != SSPSR_TNF )[/B][/SIZE]
[SIZE=2][B]{[/B][/SIZE]
[SIZE=2][B]SspStatus = LPC_SSP1->[/B][/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0][B]SR[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][B] ;[/B][/SIZE]
[SIZE=2][B]}[/B][/SIZE][/LEFT]
[LEFT][SIZE=2][B]LPC_SSP1->[/B][/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0][B]DR[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][B] = *buf;[/B][/SIZE]
[SIZE=2][B]buf++;[/B][/SIZE]
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]while[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ( (LPC_SSP1->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]SR[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][B] & (SSPSR_BSY|SSPSR_RNE)) != SSPSR_RNE )[/B][/SIZE]
[SIZE=2][B]{[/B][/SIZE]
[SIZE=2][B]SspStatus = LPC_SSP1->[/B][/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0][B]SR[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][B] ;[/B][/SIZE]
[SIZE=2][B]}[/B][/SIZE]
[SIZE=2][B]Dummy = LPC_SSP1->[/B][/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0][B]DR[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][B];[/B][/SIZE]
[SIZE=2][B]}[/B][/SIZE]
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][B]return[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][B];[/B][/SIZE]
[SIZE=2][B]}[/B][/SIZE][/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][/SIZE]
[/LEFT]