SPI not Reading first byte

조회 수: 3 (최근 30일)
Antony Smith
Antony Smith 2022년 3월 22일
답변: Antony Smith 2022년 9월 30일
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?

채택된 답변

Antony Smith
Antony Smith 2022년 9월 30일
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

추가 답변 (0개)

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by