Omega Engineering IOP-241 user manual Programming Example

Page 31

5.10Programming Example

The following C program segment demonstrates how to program an IOP-241 located at I/O base address 300h. Port A will be programmed as output, and 55h will be latched at Port A. Port B will be configured with it's upper 3 bits as output and it's lower five bits as input. The upper three bits will be latched with 010b. Port C will be configured as input. Interrupts will be enabled as explained in the program comments.

outp(0x300,0x55);

/* writes 55h to Port A */

outp(0x301,0x5F);

/* writes 010b to Port B upper 3 bits*/

/* sets Port B lower 5 bits for input */

outp(0x302,0xFF);

/* initializes Port C for input */

Port_B = inp(0x301);

/* reads data from Port B */

/* Port_B(bit7) = '0' and Port_B(bit5) = '0' due to 'masking' */ Port_C = inp(0x302); /* reads data from Port C */

outp(0x306,0x76);

/* INT7 - INT4 set for Level Sensitive Active High Interrupt Mode */

/* INT3 - INT0 set for Edge Sensitive High-to-low Transition Interrupt Source */

/* External Interrupt Source Enabled */

/* External Interrupt Source set for Low-to-high Edge Sensitive Interrupt Source*/

outp(0x305,0x77);

/* Enables six Port C interrupt sources */

/* Enables INT6,INT5,INT4,INT2,INT1,INT0 */

IOP-241 Users Manual

31

Image 31
Contents 15,1*,1 WARRANTY/DISCLAIMER Standards to which Conformity is Declared Manufacturers NameManufacturer’s Address Application of Council DirectiveFor immediate technical or application assistance Servicing North AmericaServicing Europe Page Table of Contents Page List of Figures and Tables System Configuration IOP-241 FeaturesIOP-241 Client Driver for DOS Client Driver recommended EnablerClient Driver Installation Device = C\IOP241CL.SYS Command Line OptionsPage Common Problems IOP-241 Enabler for DOS Enabler Installation DEVICE=C\IOP241EN.EXE Common Problems After Completing Configuration Resource Settings in Windows 95/98 Installing the IOP-241 Under Windows 95/98Changing Resource Settings with Device Manager After Completing Configuration I/O Port Description External Interrupt Description Port C Interrupt DescriptionOffset Read/Write Register Data Port a Control Register Base +Data Port C Control Register Base + Data Port B Control Register Base +Bit Name Description Port C Interrupt Enable Register Base +Interrupt Status Register Read Only Base + Interrupt Mode Control Register Base +Summary of Interrupt Source Options Interrupt Acknowledge Register Write Only Base +Port C Interrupt Sources External Interrupt Source Summary of Input/Output OptionsProgramming Example External Connections CP-1037 Cable Assembly Optional AccessoriesUIO-37 Screw Terminal Block Bus Interface Physical DimensionsPower Requirements ConnectorVersion January 25