SPI on LPC11U14

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

SPI on LPC11U14

1,164 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by sophio on Thu Apr 12 06:34:56 MST 2012
I have ported the SPI example of LPC11C24 to my board (LPC11U14).
And I also have followed the user manual to change the settings.
I connect the MISO and MOSI to LOOPBACK test. 
[SIZE=2][LEFT][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]for[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ( i = 0; i < SSP_BUFSIZE; i++ )
{
src_addr = ([/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint8_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])i;   // source[/SIZE]
[SIZE=2]dest_addr = 0;      //destination[/LEFT]
}
[/SIZE]
However the result is:
[SIZE=2][LEFT]the send data [0]is: 160
the receive data [0] is: 0
the send data [1]is: 15
the receive data [1] is: 1
the send data [2]is: 0
the receive data [2] is: 2
the send data [3]is: 0
the receive data [3] is: 3
the send data [4]is: 52
the receive data [4] is: 4
the send data [5]is: 2
the receive data [5] is: 5
the send data [6]is: 0
the receive data [6] is: 6
the send data [7]is: 16
the receive data [7] is: 7
the send data [8]is: 8
the receive data [8] is: 8
the send data [9]is: 9
the receive data [9] is: 9
the send data [10]is: 10
the receive data [10] is: 10
the send data [11]is: 11
the receive data [11] is: 11
the send data [12]is: 12
the receive data [12] is: 12
the send data [13]is: 13
the receive data [13] is: 13
the send data [14]is: 14
the receive data [14] is: 14
the send data [15]is: 15[/LEFT]
the receive data [15] is: 15

It seems like that the receive data is the same as what i want to send. But the first byte of the send data is changed. I do not know why, could anyone help me?thanks in advance.
[/SIZE]
0 Kudos
Reply
4 Replies

1,134 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by sophio on Fri Apr 13 00:22:57 MST 2012
[SIZE=2][COLOR=#3f7f5f] [/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f][LEFT]/*****************************************************************************
** Function name: SSP_Send
**
** Descriptions: Send a block of data to the SSP port, the
** first parameter is the buffer pointer, the 2nd
** parameter is the block length.
**
** parameters: port #, buffer pointer, and the block length
** Returned value: None
** [/LEFT]
*****************************************************************************/
[LEFT][/COLOR][/SIZE][/COLOR][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [B]SSP_Send[/B]( [/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint8_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] portNum, [/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint8_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] *buf, [/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Length )
{
[/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] i;
[/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint8_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Dummy = Dummy;

[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]for[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ( i = 0; i < Length; i++ )
{
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ( portNum == 0 )
{
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* Move on only if NOT busy and TX FIFO not full. */[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]while[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ( (LPC_SSP0->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]SR[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] & (SSPSR_TNF|SSPSR_BSY)) != SSPSR_TNF );
LPC_SSP0->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]DR[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = *buf;
buf++;[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]#if[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] !LOOPBACK_MODE
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]while[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ( (LPC_SSP0->SR & (SSPSR_BSY|SSPSR_RNE)) != SSPSR_RNE );
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* Whenever a byte is written, MISO FIFO counter increments, Clear FIFO
on MISO. Otherwise, when SSP0Receive() is called, previous data byte
is left in the FIFO. */[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]Dummy = LPC_SSP0->DR;[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]#else[/LEFT]
[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT][/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* Wait until the Busy bit is cleared. */[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]while[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ( LPC_SSP0->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]SR[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] & SSPSR_BSY );[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]#endif[/LEFT]
[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]}
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]else[/LEFT]
[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]{
  .....[/LEFT]
[/SIZE][SIZE=2][LEFT]}
}
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
}
[/LEFT]
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f][LEFT]/*****************************************************************************
** Function name: SSP_Receive
**
*****************************************************************************/[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]void[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [B]SSP_Receive[/B]( [/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint8_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] portNum, [/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint8_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] *buf, [/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Length )
{
[/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] i;

[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]for[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ( i = 0; i < Length; i++ )
{[/LEFT]
[/SIZE][SIZE=2][LEFT][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ( portNum == 0 )
{[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]#if[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] !LOOPBACK_MODE[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]#if[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SSP_SLAVE
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]while[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ( !(LPC_SSP0->SR & SSPSR_RNE) );[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]#else[/LEFT]
[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]LPC_SSP0->DR = 0xFF;
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* Wait until the Busy bit is cleared */[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]while[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ( (LPC_SSP0->SR & (SSPSR_BSY|SSPSR_RNE)) != SSPSR_RNE );[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]#endif
#else[/LEFT]
[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]while[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ( !(LPC_SSP0->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]SR[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] & SSPSR_RNE) );[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]#endif[/LEFT]
[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]*buf = LPC_SSP0->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]DR[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
buf++;
}
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]else[/LEFT]
[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]{
  ....[/LEFT]
[/SIZE][SIZE=2][LEFT]}
}
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
}[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]#endif[/B][/COLOR][/SIZE][/COLOR][/SIZE][/LEFT]
0 Kudos
Reply

1,134 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by sophio on Thu Apr 12 23:54:46 MST 2012
sry, i forgot to put my code, here is my code

[LEFT][SIZE=2][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* SPI read and write buffer size */[/COLOR][/SIZE][/COLOR][/SIZE][/SIZE][/LEFT]

[SIZE=2][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]#define [/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]SSP_BUFSIZE 16[/SIZE]
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]#define[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] FIFOSIZE 8[/SIZE][/LEFT]
[/SIZE]

[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]#define [/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]SSP_NUM 0[/SIZE]
[SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint8_t [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]src_addr[SSP_BUFSIZE];[/SIZE]
[SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint8_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] dest_addr[SSP_BUFSIZE];[/SIZE] [/LEFT]

[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B] [SIZE=2][B]SSP_LoopbackTest[/B]( [/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint8_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] portNum )[/SIZE][/LEFT]

[LEFT][SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] i;[/SIZE]
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] ( portNum == 0 )[/SIZE][/LEFT]

[LEFT][SIZE=2]{[/SIZE][/LEFT]

[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]#if[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]!USE_CS[/SIZE] [/LEFT]

[LEFT][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* Set SSEL pin to output low. */[/COLOR][/SIZE][/COLOR][/SIZE][/LEFT]

[LEFT][SIZE=2]GPIOSetValue( PORT0, 2, 0 );[/SIZE][/LEFT]

[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]#endif[/COLOR][/SIZE][/COLOR][/SIZE][/B][/LEFT]

[LEFT][SIZE=2]i = 0;[/SIZE]

[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]while[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] ( i <= SSP_BUFSIZE )[/SIZE]
[LEFT][SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* to check the RXIM and TXIM interrupt, I send a block data at one time[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]based on the FIFOSIZE(8). */[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2]SSP_Send( portNum, ([/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint8_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] *)&src_addr, FIFOSIZE );[/SIZE] [/LEFT]
[/LEFT]



[LEFT][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* Wait until the Busy bit is cleared. */[/COLOR][/SIZE][/COLOR][/SIZE][/LEFT]

[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]while[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] ( LPC_SSP0->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]SR[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] & SSPSR_BSY );[/SIZE] [/LEFT]

[LEFT][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* If RX interrupt is enabled, below receive routine can be [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]also handled inside the ISR. */[/COLOR][/SIZE][/COLOR][/SIZE][/LEFT]

[LEFT][SIZE=2]SSP_Receive( portNum, ([/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint8_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] *)&dest_addr, FIFOSIZE );[/SIZE] [/LEFT]


[LEFT][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* Wait until the Busy bit is cleared. */[/COLOR][/SIZE][/COLOR][/SIZE][/LEFT]

[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]while[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] ( LPC_SSP0->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]SR[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] & SSPSR_BSY );[/SIZE] [/LEFT]

[LEFT][SIZE=2]i += FIFOSIZE;[/SIZE] [/LEFT]

[LEFT][SIZE=2]}[/SIZE][/LEFT]

[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]#if[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]!USE_CS[/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* Set SSEL pin to output high. */[/COLOR][/SIZE][/COLOR][/SIZE][/LEFT]

[LEFT][SIZE=2]GPIOSetValue( PORT0, 2, 1 );[/SIZE][/LEFT]

[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]#endif[/COLOR][/SIZE][/COLOR][/SIZE][/B][/LEFT]

[LEFT][SIZE=2]}[/SIZE]

[SIZE=2]....[/SIZE] [/LEFT]



[LEFT][SIZE=2][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int [/COLOR][/SIZE][/COLOR][/SIZE][/B][/SIZE][SIZE=2][SIZE=2][B]main[/B] ([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2])[/SIZE][/SIZE][/LEFT]

[LEFT][SIZE=2][SIZE=2]{[/SIZE][/SIZE][/LEFT]

[LEFT][SIZE=2][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] i;[/SIZE] [/LEFT]

[LEFT][SIZE=2]SystemInit();[/SIZE] [/LEFT]

[LEFT][SIZE=2]SSP_IOConfig( SSP_NUM ); [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* initialize SSP port*/[/COLOR][/SIZE][/COLOR][/SIZE][/LEFT]

[LEFT][SIZE=2]SSP_Init( SSP_NUM ); [/SIZE][/LEFT]

[LEFT][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* Initialize GPIO (sets up clock) */[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f5f][/LEFT]
[/COLOR][/SIZE][SIZE=2]GPIOInit();[/SIZE]

[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]for[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] ( i = 0; i < SSP_BUFSIZE; i++ )[/SIZE][/LEFT]

[LEFT][SIZE=2]{[/SIZE][/LEFT]

[LEFT][SIZE=2]src_addr = ([/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint8_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])i;[/SIZE][/LEFT]

[LEFT][SIZE=2]dest_addr = 0;[/SIZE][/LEFT]


[LEFT][SIZE=2]}[/SIZE][/LEFT]


[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][B]while[/B][/COLOR][/SIZE]
[LEFT][/COLOR][/SIZE][SIZE=2][COLOR=#000000](1) [/COLOR][/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// loop forever added[/COLOR][/SIZE][/COLOR][/SIZE]

[SIZE=2][B]{[/B][/SIZE]
[LEFT][SIZE=2][B]SSP_LoopbackTest( SSP_NUM );[/B][/SIZE][/LEFT]
[/LEFT]



[LEFT][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][B]for[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][B] ( i = 0; i < SSP_BUFSIZE; i++ )[/B][/SIZE][/LEFT]



[LEFT][SIZE=2][B]{[/B][/SIZE]
[LEFT][B][SIZE=2][COLOR=#642880][SIZE=2][COLOR=#642880]printf[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"the send data [%d]is: %d\n"[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][B], i,src_addr);[/B][/SIZE]
[B][SIZE=2][COLOR=#642880][SIZE=2][COLOR=#642880]printf[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"the receive data [%d] is: %d\n"[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][B],i, dest_addr);[/B][/SIZE]
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][B]if[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][B] ( src_addr != dest_addr )[/B][/SIZE]
[SIZE=2][B]{[/B][/SIZE]
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]while[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]( 1 ); [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* Verification failed */[/COLOR][/SIZE][/COLOR][/SIZE][/B]
[SIZE=2][B]}[/B][/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] 0;[/B][/SIZE][/LEFT]
[/LEFT]


[LEFT][SIZE=2][B]}[/B][/SIZE][/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][/SIZE]
0 Kudos
Reply

1,134 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by gbm on Thu Apr 12 07:44:57 MST 2012
It's not possible to guess what might be the nature of your problem without seeing your bad code used to send, receive and display the SPI data.
0 Kudos
Reply

1,134 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Apr 12 07:29:25 MST 2012

Quote: sophio
[SIZE=2]It seems like that the receive data is the same as what i want to send. But the first byte of the send data is changed. I do not know why, could anyone help me?thanks in advance.
[/SIZE]



Don't know what you are doing in detail, but reading first 8 bytes wrong indicated that that's a FIFO problem :rolleyes:


Quote:

11.3 Features
• Compatible with Motorola SPI, 4-wire TI SSI, and National Semiconductor Microwire
buses.
• Synchronous Serial Communication.
• Supports master or slave operation.
• [COLOR=Red]Eight-frame FIFOs for both transmit and receive.[/COLOR]
• 4-bit to 16-bit frame.

0 Kudos
Reply