Dear all,
I'm trying to do a very simple thing : send some SPI to a peripheral (see model attached). The thing is that the peripheral needs its CS to be pulled down just before the transfer and pulled back up at the end. To do this, I used the block ordering function, but I had to introduce a lot of NOPs. The SPI block orders the next block as soon as it has transmitted the send request to the SPI peripheral, it does not wait for the transfer to be effectively over.
The current method works, but I wondered if there was a more CPU friendly way, as this is quite ressource consuming.
Thanks,
Martin
A more friendly way to create a chip select with SPI ?
A more friendly way to create a chip select with SPI ?
- Attachments
-
- interfacage_spi.mdl
- Model with CS
- (31.77 KiB) Downloaded 1047 times
-
- Site Admin - Expert
- Posts: 616
- Joined: Wed Mar 07, 2007 11:23 pm
- Location: Bayonne- France
- Contact:
Re: A more friendly way to create a chip select with SPI ?
Hi Martin,
This is your original solution: The first solution I propose is to disable the Chip first, and enable it just after... The second solution I propose is to configure the SPI read/write so as to read and write a data. In this way, the SPI block waits for the SPI communication to finish. Here is the model with the three solutions. These are not going to work all together. Delete at least two solutions! I corrected mistakes about sampling time. I strongly recommend using the "sample time color" option of simulink!
Lubin
PS : I see that you were inscribed to the forum. You should loggin to the forum before writting message. It allows to get mail when a response is given and other usefull options ( also less administration task for me...)
This is your original solution: The first solution I propose is to disable the Chip first, and enable it just after... The second solution I propose is to configure the SPI read/write so as to read and write a data. In this way, the SPI block waits for the SPI communication to finish. Here is the model with the three solutions. These are not going to work all together. Delete at least two solutions! I corrected mistakes about sampling time. I strongly recommend using the "sample time color" option of simulink!
Lubin
PS : I see that you were inscribed to the forum. You should loggin to the forum before writting message. It allows to get mail when a response is given and other usefull options ( also less administration task for me...)
Re: A more friendly way to create a chip select with SPI ?
Hi Lubin,
Thanks for your reply.
I tried the 2 options, but I think I'm doing some mistakes as the CS goes back to disable state in your last option, before all bits are effectively transmitted. The 2nd option is working but is less optimal for me, as the CS disable commands the latch of my SPI DAC, and thus is happening 1 cycle later here.
Any ideas ?
Thanks,
Martin
Thanks for your reply.
I tried the 2 options, but I think I'm doing some mistakes as the CS goes back to disable state in your last option, before all bits are effectively transmitted. The 2nd option is working but is less optimal for me, as the CS disable commands the latch of my SPI DAC, and thus is happening 1 cycle later here.
Any ideas ?
Thanks,
Martin
-
- Site Admin - Expert
- Posts: 616
- Joined: Wed Mar 07, 2007 11:23 pm
- Location: Bayonne- France
- Contact:
Re: A more friendly way to create a chip select with SPI ?
Try to check "Wait for incomming data (slave mode)" and uncheck "Wait for previous operation to finish, and reset before read".
The block menu is not very clear yet. I'll try to make it more clear in the next version...
The block menu is not very clear yet. I'll try to make it more clear in the next version...
Who is online
Users browsing this forum: No registered users and 9 guests