lpc51u68 spi slave transmits duplicate bytes

cancel
Showing results for 
Search instead for 
Did you mean: 

lpc51u68 spi slave transmits duplicate bytes

450 Views
Contributor I

i'm trying to create SPI slave API for my application using lpcxpresso51u68 board and i'm using SDK_2.5.0_LPC51U68.

i'm using master and slave from same board.my sample code for testing slave api is very simple, that is"transfer of 2 packets(3 bytes each)  between master and slave".

i gone thorugh spi interrupt slave example in sdk and created my api.

what i'm doing in api is:

1. configuring the pins

2. calling SPI_SlaveInit() with application defind configuration

3. calling SPI_SlaveTransferCreateHandle() to handle the irq and user callback to refill the next packet

4.caliing SPI_SlaveTransferNonBlocking()

in isr:

4.calling SPI_SlaveTransferHandleIRQ.

so,when i'm sending one packet and receiving one packet it seems to work perfectly.but when it is more than one packet slave loads duplicate byte into tx shift register after first packet (i thought i'm facing similar problem after i read this thread K22 DSPI in Slave Mode Sometimes Has Duplicate TX Bytes )

actually my sample application code is:

   1.sending 0x03,0x05,0x07 from master to slave <-> responding with 0x02,0x04,0x06 from slave to master(first packet working perfectly)

   2.sending 0x09,0x0b,0x0d from master to slave <-> responding with 0x08,0x0a,0x0c from slave to master(but here slave is sending 0x08,0x08,0x0a)

extra thing i did: in second packet i read 4 bytes on master side and it gave me 0x08,0x08,0x0a,0x0c

so,does this mean slave adds one duplicate byte to tx shift register at the end of first packet?

if that is the case then how can i clear that.it's not mentioned anywhere in lpc51u68 manual about spi slave constraints.

if i'm facing same problem as https://community.nxp.com/thread/466937 this one,then the solution mentioned in that thread will cost me some things in my application side.

i'm struck at this one for a week.someone help me to solve this

also i attached output from my application

Labels (1)
0 Kudos
10 Replies

35 Views
Contributor I

hi,

   here i attached the my code where i got the problem.I created this driver with help of sdk example.and also i attached the oscilloscope results.

And yesterday i tried one solution(Line Number:263-266 on spi_mcux_lpc.c file).it worked out also but don't know how exactly it's working.can you explain me with that also..

Thank you,

Regards,

Ananth.

0 Kudos

35 Views
NXP TechSupport
NXP TechSupport

Hello,

 

Sorry for the delay, glad to hear that is working now,

This could be happening because the value is being loaded twice to the shift register,

This because of the CS is held low between transfers,

it is possible that the 0x08 is already loaded before the second transfer begins and the flush of the FIFO

when the first transfer ends flush the 0x08 already loaded.

 

Hope it helps,

Regards,

Aldo.

0 Kudos

35 Views
Contributor I

hello,

   Thanks for the reply aldo.I too thought the problem is due to value being loaded into shift register again.But can you please explain me little bit more theoretically? why that is happening and why it not handled internally.

Thank You,

Regards,

Ananth.

0 Kudos

35 Views
NXP TechSupport
NXP TechSupport

Hello,

 

I see that you are using the slave example from the SDK, if possible please try the SPI interrupt example,

this example, one spi instance as master and another spi instance as slave. Master sends a piece of data to slave,

and check if the slave received  the correct data.

 

Thank you.

Regards,

Aldo.

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

35 Views
Contributor I

Thanks for the response.I already tested spi interrupt example with one instance as master and another one as slave,that is working fine.But when i'm trying to send more than packet it gives one duplicate byte.

0 Kudos

35 Views
NXP TechSupport
NXP TechSupport

Hi,

 

Could you check with an oscilloscope that the slave is actually sending the first byte twice?

 

Regards,

Aldo.

0 Kudos

35 Views
Contributor I

Yes i checked with an oscilloscope.the result is

1) sending 0x03,0x05,0x07 from master to slave <-> responding with 0x02,0x04,0x06 from slave to master(first packet working perfectly)

2) sending 0x09,0x0b,0x0d from master to slave <-> responding with 0x08,0x0a,0x0c from slave to master(but here slave is sending 0x08,0x08,0x0a)

If you want to see the waveforms, i'll upload it.

and you can refer this threa also https://community.nxp.com/thread/466937 , my problem is similar to this one.

Thank you

0 Kudos

35 Views
NXP TechSupport
NXP TechSupport

Hello,

Sorry for my long delay could you share with me the code you are using,

I haven't been able to replicate this issue at my side,

Regards,

Aldo.

0 Kudos

35 Views
Contributor I

Hi,

   sorry,little busy with other project.Actually after this problem happened,i have tested driver example given in sdk(lpcxpresso51u68).That also gives me same problem.anyway i'm sharing example code here.waiting for your reply.

Thank You

Regards,

Ananth.

0 Kudos

35 Views
NXP TechSupport
NXP TechSupport

Hi Ananth,

I tried with SDK and I have no problems at my side,

the example code you shared is the same as the one in the SDK,

could you share the project which gave you the original issue?

Thank you,

Regards,
Aldo.

0 Kudos