cancel
Showing results for 
Search instead for 
Did you mean: 

How to set delay on last clock within SPI communication?

DKim.1527
Associate

Hello,

I'm beginner for the STM32 core for developing motor encoder signal acquisition device.

Currently I`m using STM32L432KCU6 and RMB30SI Absolute magnetic encoder. The magnetic encoder works with SSI communication protocol and it looks similar as SPI communication.

So I tried to use HAL_SPI library to mimic SSI communication protocol with STM32Cube IED and MX. However, the problem is, SSI protocol requires termination delay time (tm) as 12.5 ~ 20.5us.0690X00000As1BNQAZ.png

If I use SPI_HAL library only, it cannot generate terminal delay time. So, how can I give those delay time on last clock pulse?

I tried to find more detail information about Timer and clock, but I don`t no where to start to study. If anybody knows about this issue, please let me know :)

2 REPLIES 2
DKim.1527
Associate

The source code is attached bellow.

You should've said DATA is MISO.

After receiving data, you should simply for the data to go high, before you start inputting more data. The DS says, this is at most 20.5us so you can simply wait that long, e.g. using a timer (or just a delay if you can afford wasting time in your mcu); or you can set up an external interrupt on that pin and wait for the rising edge (with checking whether it's not already high at the time when you set that interrupt).

You should not attempt to use Rx-only on SPI, as that outputs clocks automatically and is difficult to control precisely. Rather, use full-duplex and dont' set up the MOSI pin in GPIO.

JW