Effacer les filtres
Effacer les filtres

Is this SPI speed set from the Raspberry Pi SPI read block correct?

4 vues (au cours des 30 derniers jours)
Myles Joseph
Myles Joseph le 25 Jan 2018
When using the SPI read block (2017b, rpi3b) - I believe the SPI bus speed setting in the generated code is incorrect, can anyone confirm?
I set the spi speed under configuration parameters -> hardware implementation -> target hardware resources -> SPI to 16000kHz but the generated c code file it is still hard coded to 500kHz.
Is there a way to edit the c file and recompile to test?
/* Start for MATLABSystem: '<Root>/SPI Register Read' */
95 untitled_DW.obj.isInitialized = 0;
96 obj = &untitled_DW.obj;
97 untitled_DW.obj.isInitialized = 1;
98 SSPinNameLoc = SPI0_CE1;
99 MOSIPinLoc = MW_UNDEFINED_VALUE;
100 MISOPinLoc = MW_UNDEFINED_VALUE;
101 SCKPinLoc = MW_UNDEFINED_VALUE;
102 obj->MW_SPI_HANDLE = MW_SPI_Open(0U, MOSIPinLoc, MISOPinLoc, SCKPinLoc,
103 SSPinNameLoc, true, 0U);
104 MW_SPI_SetBusSpeed(untitled_DW.obj.MW_SPI_HANDLE, 500000U);
  1 commentaire
Myles Joseph
Myles Joseph le 25 Jan 2018
It appears so because when I remake the file
sudo -f filename.mk
after changing the value from 500000 to 16000000 I start to see data as expected.
you can execute the made package by running
sudo ./filename.elf
(in the folder above)
there also seems to be some changes not made in the MW_SPI.c file as well to reflect the proper speed.
I would also like to note that to those looking to transfer a large amount of bytes (over 4096) the SPI file also seems to be modifying the output to zeros. I believe this is due to the receive buffer size that is expected on the raspberry pi. It may be the pi settings, or the generated code limiting it.

Connectez-vous pour commenter.

Réponses (1)

Myles Joseph
Myles Joseph le 25 Jan 2018
I have confirmed that if there are more than 4096 bytes requested by the block, it will return nothing. To receive a larger message via SPI, you must
  1. generate code to raspberry pi
  2. go to the folder where the files are made on rpi
  3. open up MW_SPI.c
  4. remove
if (DataLength > 4096) {
return MW_SPI........
}
5. it may be necessary to also increase the spi buffer size on the pi
/* modify /boot/cmdline.txt to include spidev.bufsiz=131072 */

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by