The nrfjprog DLL functions must be called in a specific order.
This is the recommended sequence of calling the nrfjprog DLL functions:
NRFJPROG_open_dll()
NRFJPROG_connect_to_emu_with_snr()
NRFJPROG_connect_to_emu_without_snr()
NRFJPROG_connect_to_device()
NRFJPROG_halt()
NRFJPROG_read()
or
NRFJPROG_write()
NRFJPROG_close()