When using a device such as the NI USB 8451 that has a SPI port it is important to reset the device correctly after operation, and the following will explain why.
When the device is turned on for the first time all of the SPI port pins are set up in a tristate mode, but once the device has been set into an operational state these pins are switched to master mode function and the Chip Select pin to be push-pull output driven high. This means that even after the SPI port has been used and the device reference closed, there is a possibility it could still be driving signals to the rest of the system.
Meaning that on the second run of a program/test/sequence that uses the SPI bus might not produce the same results as the first.
This VI uses the USB 8451's device drivers to programmatically enable or disable the SPI port using scripts.
Instructions
Enter the Device reference and Function (options shown below) before running VI.
Recommended - Set a value to 'delay in milliseconds' to give time for script to run.
Functions Available
Enable:
This command switches the pins on an SPI port specified using NI-845x SPI Run Script.vi to master mode function. All chip select pins are switched from tristate to push-pull output driven high.
Disable:
This command tristates the pins on an SPI port specified using NI-845x SPI Run Script.vi. It also tristates all chip select pins.
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.