Register Programming Example
This example program reads the ID and Device Type registers and then reads the Status register. Next, the program closes a signal path from channel CH031 to COM 05, writes the value 20480 (5000 hexadecimal) to register 20h and then writes the value 38 (26 hexadecimal) to register 28h. Then, the program resets the module to open all channels. A typical printout for the program is:
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h>
ViSession defaultRM,rf_mux; void err_handler();
void wait();
void main(void)
{
unsigned short reg_20h, reg_22h; /* Registers for
unsigned short reg_28h; | /* Register for both assemblies */ |
unsigned short id_reg, dt_reg; | /* ID and device type registers */ |
unsigned short stat_reg; /* status register */
/* create and open a device session */
ViStatus err;
viOpenDefaultRM (&defaultRM);
viOpen
/* reset the module */
err = viOut16(rf_mux,VI_A16_SPACE,0x04,1); if(err < VI_SUCCESS)err_handler(rf_mux,err);
/* wait 1 second (must wait at least 100 usec before writing a "0") */
wait(1);
err = viOut16(rf_mux,VI_A16_SPACE,0x04,0);
Appendix B |