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 |
Clock Sample Data Edge |
---|---|
0 |
Positive |
1 |
Negative |
2 |
Negative |
3 |
Positive |
Sample On Positive Clock Slope
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()
~ lager analog SPI.MOSI trigger spi --clk-slope positive --dut 1
Sample On Negative Clock Slope
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()
~ 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.
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)
~ 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.
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)
~ 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.
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
~ 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.
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
~ lager analog SPI.MOSI trigger spi --trigger-on cs --cs-idle low --dut 1 `