I was going to collect the power traces bound to the nRST trigger and faced with the problem.
The logic of the script is:
- Initial setup of the CW.
- Set “rising_edge” trigger mode.
- Set triggering on the “nrst” line.
- Arm the CW.
- In the loop “Reset the target board (from CW) and capture the trace based on triggering the nrst line”
The problem is the “capture” call is blocking call and I cannot reset the target board to trigger capturing.
import chipwhisperer as cw
scope = cw.scope()
target = cw.target(scope, cw.targets.SimpleSerial2)
scope.default_setup()
scope.adc.basic_mode = "rising_edge"
scope.trigger.triggers="nrst"
scope.arm()
scope.capture(poll_done=False)
# ... Blocking happens here until timeout
# How to reset the target board by
scope.io.nrst = 'low'
time.sleep(0.05)
scope.io.nrst = 'high_z'
# so that to trigger capturing via the nrst line?
The trick is that once scope.arm()
is called, the capture will happen (if the trigger is seen). scope.capture()
just handles things on the Python side.
So try this instead:
scope.io.nrst = 'low'
scope.arm()
scope.io.nrst = 'high'
scope.capture()
trace = scope.get_last_trace()
scope.sc.arm(False)
1 Like
Thanks a lot! I missed the fact the scope.arm() works asynchronous and the actual capturing happens on the trigger event.
One more question. What exactly does “scope.sc.arm(False)”?
I have found it clears “SETTINGS_ARM” parameter and ultimately calls
def setSettings(self, state, validate=False):
cmd = bytearray(1)
cmd[0] = state
self.cached_settings = state
self.sendMessage(CODE_WRITE, "SETTINGS_ADDR", cmd, Validate=validate)
and send the message to the SAM3U.
It’s actually redundant, I had forgotten that scope.capture()
will do it for you (however there is no harm in repeating the call).
It disarms the scope, which allows it to be re-armed again later.
1 Like