RTC
®
5 PC Interface Board
Rev. 1.9 e
9 Programming Peripheral Interfaces
214
Programming Examples
The following programming examples are written in PASCAL.
(1) Confirm a signal:
set_start_list(1);
...
set_io_cond_list(0, 0, 1); // set bit #0 of the 16-bit digital output port
list_jump_rel_cond(0, 1, 0); // loop until the signal is confirmed
// (i.e. bit #0 of the digital input turns HIGH)
clear_io_cond_list(0, 0, 1); // clear bit #0 of the 16-bit output
list_jump_rel_cond(1, 0, 0); // loop until the signal is confirmed
...
set_end_of_list;
execute_list(1);
(2) If the lower four bits of the digital input have the value (
0110
), set bit #1 of the 16-bit digital output,
otherwise clear it:
set_start_list(2);
...
//RTC
®
4 style: list_jump_cond($0006, $0009, get_input_pointer + 3);
//this command uses absolute addresses and is not relocatable
//the following RTC
®
5 command uses relative addresses and is relocatable
list_jump_rel_cond($0006, $0009, 3); // skip the next two commands if the state
// of the 16-bit input is (xxxx xxxx xxxx 0110)
clear_io_cond_list(0, 0, 2); // clear bit #1 of the 16-bit output and ..
//RTC
®
4 style: set_list_jump(get_input_pointer + 2);
//this command uses absolute addresses and is not relocatable
//the following RTC
®
5 command uses relative addresses and is relocatable
list_jump_rel(2); // .. skip the next command
set_io_cond_list(0, 0, 2); // set bit #1 of the 16-bit output
... // (continue)
set_end_of_list;
execute_list(2);
...
bit1 := (get_io_status AND $0002) // returns the current state of bit #1
(3) Choose between 15 small subroutines at defined memory addresses:
...
for i := 1 to 15 do
list_call_cond(i, 15-i, i*100); // call subroutine at address i*100
// if [bit #3...bit #0] (binary) = i
...
(4) Choose between 15 indexed subroutines:
...
for i := 1 to 15 do
sub_call_cond(i, 15-i, i); // call subroutine with index i
// if [bit #3...bit #0] (binary) = i
...