The program example configures IOTester-USB pins for use as an external "processor bus"
with these characteristics:
- 16-bit data bus
- 6800 bus type control signals using R/W + Eclk clocks
- /CS chip select
- RES positive reset
- Only 1 bit of 24 possible address bus bits are routed to external pins (saving pins for other purposes)
- The default bus layout configuration is used. Enables all 19 external bus signals to be located on the same connector.
- The remaining IOTester pins are I/O port pins (default)
The example shows how delays, for instance, can be generated by use of the internal timestamp counter device.
Only external I/O registers need to be defined in the driver code. All I/O registers internal in IOTester are predefined.
#include <iotester.h> // Define IOTester functions and symbolic names for internal registers
// Define symbolic register names and addresses. 16 bit register size
#define REG_ADR0 (IOT_REG16| 0x0 )
#define REG_ADR1 (IOT_REG16| 0x1 )
// Simple method to make an accurate delay generation based on poll of the
// internal IOTester-USB timestamp counter
void delay(unsigned int ms)
{
unsigned long t1;
t1 = iot_rd(IOT_TIMESTAMP) + ms; // Add delay to current timestamp value
while( iot_rd(IOT_TIMESTAMP) < t1 ); // Wait for timeout
}
void main(void)
{
// Init IOTESTER driver, search for any IOTester-USB connected to the PC
if (iot_init(0))
return; // Could not connect
// IOTester connection OK
// Configure IOTester for External bus mode
// 16 bit data, 6800 bus type, 1 bit address bus, default pin layout
iot_wr( IOT_PIN_MODE_REG, DBUS16 | ADRBUSSIZE(1));
// The reset pin is an I/O pin pre-configured to be output.
// Toggle the pin low and high to reset any external hardware.
iot_wr( IOT_IOSET_REG1, IOT_RESET_BIT ); // RES pin is high
delay(10); // Reset pulse active for 10 ms
iot_wr( IOT_IOCLR_REG1, ~IOT_RESET_BIT ); // RES pin is low
delay(100); // 100 ms for external device to settle internally
// Loop and write to I/O device(s) on external bus
for (;;)
{
iot_wr( REG_ADR0, 0xffff ); // Write 0xffff to register 0
iot_wr( REG_ADR1, 0x0000 ); // Write 0x0000 to register 1
}
}
Links to:
IOTester tool description
Example 1: Start using IOTester I/O port pins - "Single chip mode"
Example 2: Enabling the External bus
Example 3: Using Internal Devices and External bus.
Example 4: Using Target Interrupt.
Example 5: Writing portable I/O driver source code with <iohw.h>
Example 6: <iohw.h> implementation methods and definition of I/O registers
Example 7: Swapping source code between PC and target platforms