Fatal Error bad reference

In reply to tejasakulu:

spi_cfg is not a class handle, it is a class variable that should hold a handle to a spi_agent_config object. Make sure you have assigned it and is not currently null.