SPI not Reading first byte

3 vues (au cours des 30 derniers jours)
Antony Smith
Antony Smith le 22 Mar 2022
We've noticed that when using the Master SPI Read block (STM32) it is not outputing the very first byte.
The problem is that all we need is the first 2 bytes of every Read request from a sensor, and all we can get is byte 2 and more.
We believe it may be writing something on the MOSI line on the first trigger, which causes it to ignore the first incoming byte on the MISO line, which is all we are interested in (MOSI line not even connected).
Using an oscilloscope we can see the first byte is transmitted from the sensor, but no matter what configuration is set on the SPI_Read block, it is not part of the array exiting the block?
Is there a way of accessing this blocks core code, in order to disable whatever transmission is occuring on the first byte?

Réponse acceptée

Antony Smith
Antony Smith le 30 Sep 2022
To follow up on this, I did manage to find a solution that someone may find helpful one-day.
Ultimately, in order to get the 1st byte of the SPI Read Block, you need to use the SPI "Master Transfer" block instead of the "Read" block, and as an input to trigger this block, use an array of zeros from the 'Constant' block: Value = zeros(1,2,'uint8').
Hardware used: STM32L476

Plus de réponses (0)

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by