SPI Trigger

SPI triggers allows you to trigger a waveform capture from an SPI data source. This can be very useful when debugging communication between a SPI host and device. Or if you want to capture a waveform but have the trigger be based on data in an SPI data packet.

Set Clock Edge Slope of Data Sample

This setting should align with the phase and polarity of the actual SPI clock. For example, if the phase is 0, and the polarity is 0 (clock idle low, sample on rising edge), then data will be sampled on the positive slope of the clock signal.

SPI Mode to Clock Sample Edge Polarity

SPI Mode

Clock Sample Data Edge

0

Positive

1

Negative

2

Negative

3

Positive

Sample On Positive Clock Slope

set_spi_clock_slope_to_sample_on_pos_data.py
 from lager import Net, NetType

 mosi = Net.get('SPI.MOSI',
         type=NetType.Analog,
         setup_function=setup_nets,
         teardown_function=teardown_nets)

 mosi.trigger_settings.spi.set_clk_edge_positive()
Set SPI Data Sample on Positive Clock Slope
 ~  lager analog SPI.MOSI trigger spi --clk-slope positive --dut 1

Sample On Negative Clock Slope

set_spi_clock_slope_to_sample_on_neg_data.py
 from lager import Net, NetType

 mosi = Net.get('SPI.MOSI',
         type=NetType.Analog,
         setup_function=setup_nets,
         teardown_function=teardown_nets)

 mosi.trigger_settings.spi.set_clk_edge_negative()
Set SPI Data Sample on Negative Clock Slope
 ~  lager analog SPI.MOSI trigger spi --clk-slope negative --dut 1

Set SPI Data Condition

One powerful feature is to trigger a waveform capture when a specific data byte is sent or received over the bus.

set_spi_trigger_data.py
 from lager import Net, NetType

 mosi = Net.get('SPI.MOSI',
         type=NetType.Analog,
         setup_function=setup_nets,
         teardown_function=teardown_nets)

 mosi.trigger_settings.spi.set_trigger_data(bits=8, data=0xab)
Set SPI Trigger Data Byte
 ~  lager analog SPI.MOSI trigger spi --data-width 8 --data 161 --dut 1

Trigger On Timeout

Triggering on a timeout is useful when you want to trigger a waveform capture some amount of time after the SPI bus becomes active.

trigger_spi_on_timeout.py
 from lager import Net, NetType

 mosi = Net.get('SPI.MOSI',
         type=NetType.Analog,
         setup_function=setup_nets,
         teardown_function=teardown_nets)

 mosi.trigger_settings.spi.set_trigger_on_timeout(.0001)
Trigger On SPI Timeout
 ~  lager analog SPI.MOSI trigger spi --trigger-on timeout --timeout .00001 --dut 1

Trigger On CS

Triggering on the CS signal is useful when you want to make sure you capture the full SPI transmission, as the CS line will bookend the beginning and ending.

CS Idle High

Chip select line idles high and is active low.

trigger_spi_on_cs_high_to_low.py
 from lager import Net, NetType

 mosi = Net.get('SPI.MOSI',
         type=NetType.Analog,
         setup_function=setup_nets,
         teardown_function=teardown_nets)

 mosi.trigger_settings.spi.set_trigger_on_cs_low() #trigger happens when CS line goes low
Trigger On CS High To Low
 ~  lager analog SPI.MOSI trigger spi --trigger-on cs --cs-idle high --dut 1

CS IDLE Low

Chip select line idles low and is active high.

trigger_spi_on_cs_low_to_high.py
 from lager import Net, NetType

 mosi = Net.get('SPI.MOSI',
         type=NetType.Analog,
         setup_function=setup_nets,
         teardown_function=teardown_nets)

 mosi.trigger_settings.spi.set_trigger_on_cs_high() #trigger happens when CS line goes high
Trigger On CS Low To High
 ~  lager analog SPI.MOSI trigger spi --trigger-on cs --cs-idle low --dut 1     `