How to send several SPI instructions continuously

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

How to send several SPI instructions continuously

3,039 Views
hjhjhj
Contributor IV

Hi Daniel,

    To read from the EEPROM,it's necessary to send several SPI instructions continuously during a  interrupt.

22.PNG

     I try configure as follows,but there're some errors.

11.PNG

33.PNG

Is there any other way to send several SPI instructions continuously at a time to avoid the errors above?

Thank you!

HJ

9 Replies

1,848 Views
vsingh_iitkgp
Contributor I

I would suggest to use Repeating sequence stair block if you need to transfer more than 2 SPI data transfer. Use different values of repeating stair case signal values as different switch case

0 Kudos

1,848 Views
dumitru-daniel_
NXP Employee
NXP Employee

Hi hjhjhj‌,

Please have a look here: https://community.nxp.com/thread/453727  starting with 7'20''

You can implement something similar to be called from your interrupt.

Best regards,

Daniel

0 Kudos

1,847 Views
hjhjhj
Contributor IV

Hi Daniel,

     As shown below, to send the instruction to the device,it must remain selected between several sequential serial transfers.

22.PNG

      Though trying it many times,all I can configure is as follows,in which the device is not selected continuously.Can you show me the way to cofigure the Continuous selection format?

11.PNG

Thank you !

HJ

0 Kudos

1,848 Views
dumitru-daniel_
NXP Employee
NXP Employee

Hi hjhjhj‌,

In this case you need to activate the Continuous Serial Communication Clock and Continuous Peripheral Chip Select Enable:

pastedImage_1.png

pastedImage_3.png

That should do the trick. Please let me know if you managed to make it work.

Best regards,
Daniel

0 Kudos

1,848 Views
hjhjhj
Contributor IV

Hi Daniel,

The Continuous Serial Communication Clock and Continuous Peripheral Chip Select Enable are activated,but the result is not what I want,because Chip Select (S) is always driven low .As for the EEPROM,Chip Select (S) must be driven high after the rising edge of Serial Clock (C) for the last bit of the instruction,in order to make sure the instructions to be accepted and executed.

Now the problem is that  Chip Select (S) should be  configurable to  be driven high at anytime.Can you help me solve it?

11.PNG

Thank you !

HJ

    

0 Kudos

1,848 Views
dumitru-daniel_
NXP Employee
NXP Employee

Hi hjhjhj‌,

I'm going to look into this and check if there's a way to accomplish what you need. Unfortunately i do not own such a slave, so the only thing i can do is to test with an oscilloscope. If i get something working the way you need i'll let you know.

Thank you!

Daniel

0 Kudos

1,848 Views
hjhjhj
Contributor IV

Hi Daniel,

     Is there any progress in this  problem?

0 Kudos

1,848 Views
dumitru-daniel_
NXP Employee
NXP Employee

Hi hjhjhj‌,

According with the MPC5744P reference manual, the SPI modules supports:

Programmable serial frame size: 4 to 16 bits
•    SPI frames longer than 16 bits can be supported using the continuous selection format.

As can be seen you will need to use the continuous selection format to achieve 32b transfers.

The SPI Transmit blocks supports the Continuous Peripheral Chip Select Enable option which set the CONT bit. If set to 1 (enabled) the Chip Select signal is kept low (active)

pastedImage_2.png

The generated code for transmit is injected into the Simulink Step function which is called based on the Solver Fixed Time Size (fundamental sample time)

pastedImage_3.png

This give us the possibility to control when to enable of disable such option.

In Simulink, there are multiples ways to implement the set/reset of this bit.

- one way is to use a switch block and selected between the transfers when you want the CONT bit to be 1 (continuously) and the cases when you want independent transfers CONT bit to be 0

- use a custom S-function builder to set only this CONT bit at the end of step function.

Attached is an example using the SWITCH block. 

Using this example you will have to develop your own logic to select the timing when you wish to sent/receive continuous SPI messages. Also, keep in mind you have the EOQ bit that could help you to decide when/what to transmit.

Using this example i could set the SPI to send 2 msg@16bit continuously and then switch to 2 independent messages.

pastedImage_5.png

Hope this will inspire you to solve the issue.

Best regards,

Daniel

1,848 Views
hjhjhj
Contributor IV

Hi Daniel,

      The datasheet of the slave is as shown in the attachment and I'm looking forward to your good news.

Thank you !

HJ

0 Kudos