TX7410 Operation Manual
40
8)
For some commands that will take a long time to execute, for example Correction
command, the controller should keep waiting to avoid the next command being
lost when TX7410 is executing the former command.
Sample Program for Serial Interface
The following is a C language sample program under DOS environment. The main function
may be expanded by users, and the other sub functions teach you how to input or output
a character string via the RS232 interface.
#define PORT 0
#include "dos.h"
#include "stdio.h"
#include "stdlib.h"
#include "ctype.h"
#include "conio.h"
void port_init( int port,unsigned char code );
int check_stat( int port ); /* read serial port state(16bit) */
void send_port( int port,char c );
/* send a character to serial port */
char read_port( int port ); /* recive a character form serial port */
void string_wr( char *ps );
/* write a string to serial port */
void string_rd( char *ps );
/* read a string from serial port */
char input[256];
/* quary recieve bufer */
main()
{
port_init( PORT,0xe3 );/* initilize serial port:baud = 9600,no verify,1 bit stop,8 bit data
*/
string_wr( "trig:sour bus;*trg" );
string_rd( input );
printf( "
\
n%s",input );
string_wr( "freq 10khz" );
string_wr( "func:imp:apar cs;bpar d" );
string_wr( "voltage:level 0.3v" );
}
/* write string to serial port */
void string_wr( char *ps )
{
unsigned char c;
int m,n;
while( check_stat(PORT) & 256 ) read_port( PORT );/* read data until null */
for( m = 1000;m;m-- ) /*communication handshake:wait until ready*/