LPC11U14 : SPI problem

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

LPC11U14 : SPI problem

985 Views
lpcware
NXP Employee
NXP Employee
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]
0 Kudos
Reply
4 Replies

975 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by NXP_Europe on Mon May 28 15:09:14 MST 2012
hello Dino,

On the market there are relatively cheap USB-loggers available.
These loggers show e.g. SPI-protocol and often a variety of other protocols too.
Messages are shown as data-bytes.

Can be very handy, when writing software.
0 Kudos
Reply

975 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Dino on Fri May 25 00:14:23 MST 2012
Many Thanks, the code is OK I tested the wrong pin.
0 Kudos
Reply

975 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu May 24 02:14:40 MST 2012

Quote: Pellek
[COLOR=#7f0055][SIZE=2]For SSEL1, I'm not sure, but pins are configured pull-up by default...[/SIZE][/COLOR]



SSEL is [COLOR=Red]output[/COLOR], no pull-up, no pull-down, no pull-left and no pull-right :)

Therefore you should see a nice low (= CS for slave) while SCK is clocking :eek:
0 Kudos
Reply

975 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Pellek on Thu May 24 01:12:20 MST 2012
Hi.
I'm not sure it will correct your problem but here's my 2 cents ;)

[COLOR=#7f0055][SIZE=2]You're in "Master Mode", so if you send, data will be on MOSI pin (Master Out/Slave In). So you're watching the wrong pin atm.

For SSEL1, I'm not sure, but pins are configured pull-up by default, is your pin connected to something ? maybe if you link it to any load (normal gpio for instance), you could see something. just give a try.

config seems to be ok.
[/SIZE][/COLOR]
0 Kudos
Reply