Simultaneously writing an reading SPI in slave role

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi,

I want to try to write and read SPI in slave role in the same time.

Therefor I use the function

spiffyd_exchangeData(SPIFFYD_2, SPIFFY2_MAX_NUMBER_OF_BYTES_PER_TRANSACTION-1, (const UINT8*)txbuffer, rxbuffer);

But when this function is called the Tag-Board is resetted by firmeware.

Why is a reset event triggert?

Best regards

Christoph

0 Likes
1 Solution
Anonymous
Not applicable

Hello christophkellermann

Can you try NO while loops:

1.  Configure the SPI on both Master and Slave.

2.  You must have the SPI Master feeding a clock.

3.  If there is NO Master, the device will wait forever.

Thanks

JT

michael.goetz@ebv.com

View solution in original post

0 Likes
13 Replies
Anonymous
Not applicable

Hello c k,

Question about your SPI setup:

1.  Is there a SPI Master supplying the clock?

Thanks

JT

0 Likes
Anonymous
Not applicable

Hi,

sure, there is a SPI Master who is generat the clock signal.

0 Likes

Which tag are you using? Did you have a chance to verify spi_comm_master and spi_comm_slave under Apps within the SDK?

0 Likes
Anonymous
Not applicable

I am using the TAG3 Board with the SDK 2.2.0. I have already checked an run the two sample codes.

In spi_comm_slave there isn't a call from the function "spiffyd_exchangeData".

When I am using the the functions

spiffyd_slaveTxData(SPIFFYD_2, SPIFFY2_MAX_NUMBER_OF_BYTES_PER_TRANSACTION, txbuffer);

spiffyd_slaveRxData(SPIFFYD_2, SPIFFY2_MAX_NUMBER_OF_BYTES_PER_TRANSACTION, rxbuffer);

the read an write works, but the TX-register seems not to be immediately updated.

But the problem ist, when I am try to implement a SPI echo (master sends one byte and the slave answer with the same byte with a delay of one byte.) The slave sends the byte in the second transaction, when CS line is high and then set for the second transaction to low.

Because of that problem I try to use the  spiffyd_exchangeData function.

How can I solve the two problems?

Thank you for your help.

0 Likes

Below thread may share some insights:

SPI Slave Tx FIFO

0 Likes
Anonymous
Not applicable

Thanks for the reference link, but that does not solve the problem. The Problem of this thread is not successfully solved.

Do you or your developers have a solution?

0 Likes

Did you start with the sample provided within the SDK (spi_comm_master and spi_comm_slave) with the TAG3 development board?

Have you taken a look at the example SPI Slave code provided within the WICED™ Smart Hardware Interfaces guide? Use this thread when referencing that guide as it refers to the SoC: BCM920736 SPI master 2 pin configuration

Have you seen the BUS Pirate - Hardware overview - Training for SPI.pdf that thomasyounsi posted here?  Are you using a similar tool for SPI debug on your side?

Note that the SPI interface is pretty tricky to debug unless you start with the sample application noted above.

0 Likes
Anonymous
Not applicable

Thanks for the information. But this was not helpful for the problem with the spiffyd_exchangeData function and the restart.

Please give me a meaningfully answer than the times before. Thanks a lot.

0 Likes

As you have mentioned the " Tag-Board is resetted by firmware." when you call that functions its because of the watchdog firmware that is implemented.

One of the possible causes for this to happen are if you trying to read/write more than fifo length. Would suggest to split the data into chunks such that it does not overflow the tx fifo or rx fifo. If you have already tried this and still see the issue, would suggest to share your application code so we can have a look at our end and let you know.

thnx

vik86

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Thanks for the idea with the fifo length. But that is not the problem.

I attach my spi test program.

In the file spi_slave.c the function void masterToSlaveReceive(void) is important.

It waits for CS-Signal and then receives three bytes. If the third byte is a 0x01 (from spi master) the following bytes should be 0xAA otherwise a 0x00. So the slave should send 0xAA immediately after receiving 0x01 until CS line is unselected.

I try two variations.

1)  Update the tx buffer by

spiffyd_slaveTxData(SPIFFYD_2, SPIFFY2_MAX_NUMBER_OF_BYTES_PER_TRANSACTION-3, txbuffer);

spiffyd_slaveRxData(SPIFFYD_2, SPIFFY2_MAX_NUMBER_OF_BYTES_PER_TRANSACTION-3, rxbuffer);

But the TAG 3 board sends this data in the next spi transaction. So how can I update the spi fifo register immediately?

2) Parallel sending and receiving

spiffyd_exchangeData(SPIFFYD_2, SPIFFY2_MAX_NUMBER_OF_BYTES_PER_TRANSACTION-3, (const UINT8*)txbuffer, rxbuffer);

The effect is that the TAG 3 board resets via watchdog. Why?

Note: I don't use the FC0 line!

0 Likes
Anonymous
Not applicable

Hello c k

From the Developers:

At first glance at your attached code the developers recommend the following:

1.  It appears that you are using too many while() loops in your code which may be causing a watchdog reset.
2.  Your App runs for more than 2s without letting the rest of the event-driven system run.
3.  You must refactor your code to make it event driven adhering to bluetooth event protocols.

Thanks,
Hope this helps

0 Likes
Anonymous
Not applicable

Hi,

thank your for the tips from your developers.

But the reset event from the watchdog comes only when I am using the parallel sending (spiffyd_exchangeData). The while-loops could not be the problem.

But even when I am reducing the while loops the reset problem still exists.

Can I manually call the watchdog-event?

What about updating the fifo-register:

Update the tx buffer by

spiffyd_slaveTxData(SPIFFYD_2, SPIFFY2_MAX_NUMBER_OF_BYTES_PER_TRANSACTION-3, txbuffer);

spiffyd_slaveRxData(SPIFFYD_2, SPIFFY2_MAX_NUMBER_OF_BYTES_PER_TRANSACTION-3, rxbuffer);

But the TAG 3 board sends this data in the next spi transaction. So how can I update the spi fifo register immediately?

The bluetooth things are not important at the moment.

0 Likes
Anonymous
Not applicable

Hello christophkellermann

Can you try NO while loops:

1.  Configure the SPI on both Master and Slave.

2.  You must have the SPI Master feeding a clock.

3.  If there is NO Master, the device will wait forever.

Thanks

JT

michael.goetz@ebv.com

0 Likes