expandIO-USB TM Driver-free USB I/O expander for software-controlled peripherals Summary expandIO-USB is an ultra-low cost USB I/O expander. It allows a PIC microcontroller to be remotely controlled via USB, significantly reducing time-to-market for simple USB-based products. expandIO-USB provides control of most microcontroller functions and is available for PIC18F14K50, LF2455, and LF4455 microcontrollers. expandIO-USB uses the Human Interface Device (HID) USB profile. It does not require USB drivers and so is immediately plug-and-play compatible with present and future Windows, Linux and Mac operating systems. expandIO-USB is supplied as HexWax firmware, or preprogrammed and pre-configured microcontroller is larger volumes. USB Features True HID plug and play - No drivers required Ultra-low cost, single chip solution Low speed version can use a low cost resonator, 200 commands per second PC Commands sent by USB USB Status Indicators .. . Crystal / Resonator expandIO-USB A/D-I/O-SPI-I2C-UNI/O I/O under PC control No microcontroller programming required I/O Expander Command Set Set/Get register byte/bit Set/Get digital I/O port/bit Get analog input Full speed version can process up to 32K commands per second Interrupt Event Product name, manufacturer name, serial number, GUID & 122-byte EEPROM configurable over USB SPI / I2C / UNI/O synchronous serial master No Vendor ID / Product ID registration required USB 2.0 compatible USB / Self Power inputs DIL, SSOP, TSSOP and QFP packages Multiplex Output (for LED displays) Stream Data Wait PC peripheral control Embedded system peripheral control Rapid development of USB products PLCs for testing and automation Peripheral Features Table 1. Peripheral feature matrix Base PIC18F 14K50 2455 4455 Microcontroller I/O pins 12 21 32 Interrupt on edge 3 3 3 Interrupt on change 0 4 4 Count / Compare / 1 2 2 Pulse Width Modul'n UART (not buffered) 1 1 1 SPI/I2C (as master) 1 1 1 UNI/O (as master) 12 21 32 Comparators 2 0 2 10-bit A to D 9 10 13 Timer 8-bit 1 1 1 Timer 16-bit 3 2 3 Product ID, low speed 0120 0129 012A (hex) Product ID, full speed 012D 0132 0133 (hex) DIL, DIL,SOIC DIL,TQFP Available packages SSOP 22-Nov-10 Matrix Scan (for matrix keyboards) Applications Optional Configured, Suspended and AllSystems-Go, Tx / Rx indications p1 Figure 1: How expandIO-USB works expandIO-USB Firmware Factory USB Product Family USB-232 asynchronous serial interface TEAleaf-USB security and authentication dongle expandIO-USB I/O expander USB-SPI synchronous serial slave interface USB-I2C synchronous serial slave interface USB-DAQ data logger USB-FileSys USB embedded file system Firmware Factory Ltd 2 Marshall St, 3rd Floor London W1F 9BB, UK sales@firmwarefactory.com support@firmwarefactory.com HW148-18 www.firmwarefactory.com Electrical Specifications Table 2. Electrical Specifications Operating voltage Vdd, 18LFx45x 2.7V - 5.5V Operating voltage Vdd, 18F14K50 1.8V - 5.5V Typical/max supply current, Vdd = 5.0 10mA / 21mA Typical/max Sleep current, Vdd = 5.0 0.1A / 2A Operating Temperature -40C to +85C Refer to base microcontroller data sheet for further information Part Numbering expandIO-USB parts are numbered as follows: expandIO-USB-XX-YY-ZZ where XX is FS for full speed, LS for low speed; YY is DIL for dual-in-line, PT for TQFP, or SS for SSOP; ZZ is 20, 28, 40 or 44 according to the number of pins. If XX is not specified, FS should be assumed. ZZ is only given only for DIL packages. The following parts are widely stocked by distributors: expandIO-USB-FS-DIL-28 expandIO-USB-PT-FS expandIO-USB-SS Basic Operation To the PC (`host'), expandIO-USB looks like a Human Interface Device (HID) with which it may exchange information using simple commands. Commands are provided to control most of the I/O and peripherals of the microcontroller, allowing all product development to take place in the PC software application. No microcontroller firmware development is required. expandIO-USB is available as a full speed device, which can process up to 32K commands per second, or as a low speed device which can process up to 200 commands per second. Pin Functions Dedicated pin functions are shown in table 3. Note that some output pins are in a tri-state condition until ~20s after power-on. Pin-outs for the different packages are shown in Appendix II. Table 3. Dedicated pin functions NMCLR Vpp Vusb DPGC D+ PGD Vss Vdd OSC1 OSC2 p2 Description Reset (active low) TEAclipper Vpp USB supply filter USB data TEAclipper PGC USB data+ TEAclipper PGD Power ground reference Power positive input Oscillator output Oscillator input 22-Nov-10 Vss, Vdd, Vusb Vss is the power supply ground reference. Vdd and Vusb should be connected to a regulated supply, for example regulated from the USB bus power. OSC1, OSC2 OSC1 and OSC2 should be connected to a 12MHz parallel cut crystal circuit with 22pF capacitors. It may be replaced with a 12MHz resonator with 0.25% total tolerance. In low speed devices, it may be replaced with a 12MHz resonator with 1.5% total tolerance, e.g. Murata 81-CSTCE12M0G55-R0. Vpp, PGC, PCD TEAclipper programming pins. Refer to the Delivery and Programming section for details. Note that the Vpp pin may be subject to voltages as high as 12V during programming. Reset Contact us for information about availability of other parts. Name These pin functions, and optional USB status indicator pins, are described in detail below: This pin should normally be pulled high via a 22k resistor. It may be pulled low to reset the device. Tx Indication Output for connecting to a transmit indication LED. It turns on for approximately 100ms when data has been transmitted to the host. This setting is available as active high or low on any I/O pin. Rx Indication Optional output for connecting to a receive indication LED. It turns on for approximately 100ms when data has been received from the host. This setting is available as active high or low on any I/O pin. Tx / Rx Indication Optional output for connecting to a transmit / receive indication LED. It turns on for approximately 100ms when data has been transmitted to or received from the host. This setting is available as active high or low on any I/O pin. Configured Indication Optional output that indicates when the USB interface has completed configuration and the host has indicated that the device may draw its full power setting. Prior to configuration completing, the device should draw no more than 100mA from the bus. Note that the configured indication continues to stay high when in suspend mode, even though the device must consume no more than 100A during suspend. This setting is available as active high or low on any I/O pin. Suspend Indication Optional output that indicates when the host is entering a sleep state (active low). In this state, the device should draw no more than 100A from the bus, excluding the consumption of the expandIO-USB chip. This setting is available as active high or low on any I/O pin. expandIO-USB HW148-18 www.firmwarefactory.com All-Systems-Go Indication Serial Number Optional output that indicates when the expandIO-USB is configured and not suspended, and full power may be drawn. The Serial Number data is a Unicode string of up to 61 characters plus zero terminator. The host application can read this data using a Get Feature request for string 3. The Serial Number is a unique string which you can use to differentiate one physical device from other devices with the same expandIO-USB Vendor ID / Product ID / Product GUID combination. Unless otherwise configured, the default value is a unique value. General I/O pins Any pin not configured as detailed above may be used as a general I/O pin and manipulated using commands. All such pins initialize as digital inputs. Refer to the base controller data sheets for electrical specifications of these pins. Device Fuses Fuses are non-volatile settings you may select to customize your device. For information on how to modify them, refer to the device configuration section. USB Status Indicators Each pin that can take a USB-status indication function has a fuse to specify whether the port serves this function, or is available as general I/O. Write Lock Once the write lock bit is set, all commands which change the device strings and fuses will have no effect. Unless otherwise configured, the default is unlocked. Power Setting The device can be configured to draw a maximum of up to 500mA. If more than 100mA is specified, the Host Ready and All Systems Go indicators will only assert if the host has the full requested power available. Custom VID / PID Personalized Vendor and Product IDs are not required. However, you may customize them if you wish. Unless otherwise configured, the default IDs are given in table 1. Device Strings Device strings are non-volatile Unicode strings stored by the expandIO-USB and which may be read by the host PC and all its applications. For information on how to modify them, refer to the customization section. Product Name The manufacturer name is a Unicode string of up to 61 characters plus zero terminator. The host application can read this data using a Get Feature request for string 1. The host PC commonly displays this string while it is installing the default HID driver when it is first inserted. Unless otherwise configured, the default value is "expandIO-USB". Product GUID The product GUID is a Unicode string of up to 61 characters plus zero terminator. The host application can read this data using a Get Feature request for string 4. The product GUID is a string which you can use to differentiate a product from other devices with the expandIO-USB Vendor ID / Product ID combination. It should be the same for all products of the same type. Unless otherwise configured, the default value is "No GUID". Config (EEPROM) String The configuration data is a Unicode string of up to 61 characters plus zero terminator (i.e. 122 bytes). You can use it as you wish to store configuration data on the product which the host software can access. The host application can read this data using a Get Feature request for string 5. Unless otherwise configured, the default value is "No Config". Application Circuits The following circuits are typical implementations of the expandIO-USB. Suggested component values are shown in table 4. Table 4. Suggested component values Label Component R1, R2 22k resistor R6 1k resistor R2x 470 resistor T1 P-channel Mosfet, e.g. NDS352P LED1x Light emitting diode C1 10F capacitor C2, C3 22pF capacitor C4, C6, C7 100nF capacitor C8 470nF capacitor X1 12MHz parallel cut crystal Figure 2 is the suggested circuit for expandIO-USB. Manufacturer Name The manufacturer name is a Unicode string of up to 61 characters plus zero terminator. The host application can read this data using a Get Feature request for string 2. The host PC commonly displays this string while it is installing the default HID driver when it is first inserted. Unless otherwise configured, the default value is "Firmware Factory Ltd". p3 22-Nov-10 expandIO-USB HW148-18 www.firmwarefactory.com Figure 2 connector should be left unconnected. The ID pin on the mini connector permits the distinction of A and B plugs. The micro connector pin-out is the same as the mini connector. General purpose I/O One LED circuit for each indicator (Active low shown) C3 Vss OSC2 Suspend Configured AllSysGo Tx / Rx Ind Tx Ind Rx Ind Vdd R2x X1 C2 expandIO-USB Vss D+ PGC Reset# Vss Vdd PGD Vusb C8 2 3 Vss TEAclipper connector 1 Vdd R2 C7 C6 Vss Figure 4 Common USB pin-outs for male connectors OSC1 4 4 3 D- USB 2 Vdd 1 5 Vss Table 5. USB Connection Key Cable Description color Std Mini 1 1 Vcc Red +5V (can dip to 4.08V) 2 2 D- White Data - 3 3 D+ Green Data + Type A: Connect to ground - 4 ID - Type B: Not connected 4 5 Gnd Black Signal ground Pin C1 Oscillator X1/C2/C3 may be replaced by a low-cost resonator, provided its frequency tolerance is greater than 0.25% (full speed devices) or 1.5% (low speed devices). C1 and C6 should be placed close to the USB connector. Capacitor(s) C7 should be placed near the Vss and Vdd pin(s) of the expandIO-USB and are only required if they would be some distance from C6. C8 is a filter capacitor for an internal regulator and is required. The TEAclipper connector is for in-circuit programming of devices where the firmware has been purchased from HexWax. It is strongly recommended to allow firmware updates, even if the firmware is supplied preprogrammed. Name For ultra-low cost products, it is possible to form a USB Type-A plug direct from a circuit board as shown in figure 5. This connector is only suitable for a number of insertions (~50 before cleaning is required). It is unshielded and recommended only for `dongle' type products with no cables attached. For further dimensional information, refer to figure 6-7 of the USB 2.0 Specification, in the development kit. 11.75 Power Take-Off 1.00-2.00 A device should only draw current from the USB line once USB configuration is complete and the host PC is not is sleep mode. The AllSysGo output (configured active low) can provide such a switch using the subcircuit shown in figure 3. C4 / R6 provide a slow switchon to prevent inrush current exceeding USB power limitations. 1F and 100nF smoothing capacitors are recommended on both sides of T1. 2.25 1.25 12.00 Overall PCB thickness including tracks 2.00 - 2.20 4. Vss 0.50 1.00 3. D+ 2. D- 3.00 1.00 Shoulder required to prevent over-insertion Overall PCB width 16.00 or less Figure 5 Dimensions in mm 1. Vdd Contacts plated with hard gold flash (0.25-1.27m) over nickel (2.6-5.0m) T1 Vdd Vout Host-Side Interfacing R1 C4 R6 AllSysGo Figure 3 Power considerations If the device is electromagnetically noisy, a ferrite bead is recommended on the USB Vdd supply in order to suppress any transmission of noise to the rest of the USB network. Design note AN1149 from Microchip Technology, in the development kit, discusses designs for recharging batteries using USB bus power. USB Connectors Common USB connector and cable configurations are shown in figure 4 and table 5. The shield on the p4 22-Nov-10 expandIO-USB expandIO-USB uses the Human Interface Device (HID) USB interface. It has the advantages that no device drivers are required, and that a host application can easily locate the expandIO-USB. On full speed devices, all exchanges of data (`reports') between the host and the expandIO-USB are 64 bytes in length. In HID terms, all transfers are 1ms interrupt reports of 64 bytes, to and from output ID 0 on EP1. On low speed devices, all exchanges of data (`reports') between the host and the expandIO-USB are 8 bytes in length. In HID terms, all transfers are 10ms interrupt reports of 8 bytes, to and from output ID 0 on EP1. The host software has two perform two tasks. First it has to locate the device. Then it has to communicate with it. To locate the device, enumerate all devices with Vendor ID 0x0B40 and Product ID (shown in table 1). Then use a Get Feature request for the string 4, the HW148-18 www.firmwarefactory.com Product GUID. If this matches the product GUID you configured for the device, you have located it. Bytes 1, 2 and 3 will be bytes 0, 1 and 2 of the original command, respectively Once you have located the device, you need to open a file to communicate with it. You can then send data and receive data as 64-byte / 8-byte reports as appropriate. Example: Sample source code for Windows and a Windows dynamic link library (DLL) are provided in the development kit. For a detailed description, please refer to the comments embedded in the source code and the Visual Basic example in the Excel spreadsheet. Sample source code for Mac OS and Linux is in preparation. Commands Commands are sent from the host and responses are received from expandIO in the form of HID reports. With the exception of the EXESPI, EXEI2C and EXEUNIO commands, all commands and responses are 4 bytes long. Full speed device reports contain 16 commands / responses each. Low speed device reports contain 2 commands / responses each. If fewer commands are sent in a report, the remainder of the report should be padded out with nulls. Commands are processed in order. The first byte of a command (byte 0, the leftmost byte in the examples below) is termed the identifier, and indicates the type of command. The remaining three bytes (bytes 1, 2 and 3) are termed the payload. The EXESPI, EXEI2C and EXEUNIO commands are slightly different. They may be longer than 4 bytes if they are the first and only command in the report. The response to a command will have the same identifier as the command, (unless an error occurred). Some events can also generate unprompted responses at any time. The response from expandIO-USB is buffered in the same memory as the incoming commands. Provided no unprompted responses are sent (e.g. from interrupts), any unused bytes in the response packet will be identical to the same byte location in the corresponding command. This feature may be employed to append information to allow commands and responses to be matched. Note: Accidentally sending a command in the range 0x80-0x8F can modify settings that may permanently disable the device. During product development, it is recommended that you work with a device that has been write locked using HIDconfig.exe. Devices intended for production should always be write locked. Null The identifier NULL (0x00) has no effect. The payload bytes are ignored. Example: 00 00 00 00 00 00 00 00 Null Command Null Response Error The identifier ERROR (0xFF) reports that a command could not be processed because it had no meaning. p5 22-Nov-10 expandIO-USB 12 34 56 78 Meaningless command FF 12 34 56 Error Response Get Register The identifier GETREG (0x98) retrieves value of a microcontroller register. Byte 1 specifies the register as detailed in appendix I. The response is the same as the command, except the register value is given in byte 2. Directly accessing registers requires in-depth knowledge of the base microcontroller, but it provides greater flexibility that the other commands. Refer to the base microcontroller data sheet for details. Example: 98 CC 00 00 Command - Get TMR2 register 98 CC 5A 00 Response - Value is 0x5A Set Register The identifier SETREG (0x99) sets the value of a microcontroller register. Byte 1 specifies the register as detailed in appendix I. Byte 2 specifies the new value. The response is the same as the command. Directly accessing registers requires in-depth knowledge of the base microcontroller, but it provides greater flexibility that the other commands. Refer to the base microcontroller data sheet for details. Example: 99 CC 5A 00 Command - Set TMR2 reg to 0x5A 99 CC 05 00 Response - Value set Get Register Bit The identifier GETBIT (0x9A) retrieves a single bit from a microcontroller register. Byte 1 indicates the register as detailed in appendix I and byte 2 indicates the bit (07). In the response, byte 3 is 0 for clear and 1 for set. Directly accessing registers requires in-depth knowledge of the base microcontroller, but it provides greater flexibility that the other commands. Refer to the base microcontroller data sheet for details. Example: 9A F0 06 00 Command - Get INTCON3 bit 6 9A F0 06 01 Response - Value is 0x01 Set Register Bit The identifier SETBIT (0x9B) sets or clears a single bit of a microcontroller register. Byte 1 indicates the register as detailed in appendix I and byte 2 indicates the bit (0-7). Byte 3 is 0 for clear and 1 for set. The response is the same as the command. Directly accessing registers requires in-depth knowledge of the base microcontroller, but it provides greater flexibility that the other commands. Refer to the base microcontroller data sheet for details. 9B F0 06 01 HW148-18 Command - Set INTCON3 bit 6 to 1 www.firmwarefactory.com 9B F0 06 01 Response - Bit set While making the analog measurement on an analog pin, any analog pins with index lower than the pin being measured will temporarily enter a high-impedance state. Get Port The identifier GETPORT (0x9C) retrieves value of a port. Byte 1 indicates the port (A=1, B=2...). Byte 3 specifies which bits should be set as outputs (`0') and which bits should be set as inputs (`1'). The response is the same as the command, except the port value is given in byte 2. Example: 9C 02 00 FF Command - Get Port B, all inputs 9C 02 54 FF Response - Value is 0x54 Set Port The identifier SETPORT (0x9D) sets the value of a port output latch. Byte 1 indicates the port (A=1, B=2...). Byte 2 specifies the new value. Byte 3 specifies which bits should be set as outputs (`0') and which bits should be set as inputs (`1'). The response is the same as the command. Example: 9D 02 54 00 Command - Set Port B to 0x54 all outputs 9D 02 54 00 Response - Value set Get Port Bit The identifier GETPORTBIT (0x9E) retrieves a single bit from a port. Byte 1 indicates the port (A=1, B=2...) and byte 2 indicates the bit (0-7). Byte 3 is 0 if the bit should be configured as an output and 1 if it should be configured as an input. In the response, byte 3 is 0 for clear and 1 for set. Example: 9E 02 03 01 Command - Get Port input bit B3 9E 02 03 01 Response - Value is 0x01 Set Port Bit The identifier SETPORTBIT (0x9F) sets or clears a single bit of a port output latch. Byte 1 indicates the port (A=1, B=2...) and byte 2 indicates the bit (0-7). Byte 3 bit 0 is 0 for clear and 1 for set. Byte 3 bit 1 is 0 if the bit should be configured as an output and 1 if it should be configured as an input. The response is the same as the command. 9F 02 03 01 9F 02 03 01 Command - Set Port bit B3 to output 0x01 Response - Bit set Get Analog The identifier GETANALOG (0x96) retrieves the voltage of an analog pin. Byte 1 bits 0-3 indicate which analog pin (AN0 = 0, etc). Byte 1 bit 4 is 1 if AN3 should be used as a positive voltage reference (Vref+), or Vdd / AVdd otherwise. Byte 1 bit 5 is 1 if AN2 should be used as a negative voltage reference (Vref-) or Vss / AVss otherwise. In the response the analog value is in bytes 2 (MSB) and 3 (LSB). The value ranges from 0x000 (Vss / AVss / Vref-) to 0x3FF (Vdd / AVdd / Vref+). Example: 96 16 00 00 96 16 02 36 Command: Get AN6 using Vref+ Response: V = Vref+ * (0x236/0x3FF) SetSerial (18F2450, 18F4450 support UNI/O only, not SPI / I2C.) The identifier SETSERIAL (0x93) initializes the synchronous serial SPI/I2C port or, from rev 0008, a UNI/O bus. Only one of SPI port or one I2C port can be configured. The MSSP resource is used. In the equations below Fo = 24MHz for expandIO-USB and 48MHz for USB-XP. SPI: If byte 1, bits 1 and 0 are 00, the MSSP port is configured for SPI operation. The SDO pin shown in the pin diagrams becomes the master output (MOSI), SDI pin becomes the master input (MISO), and SCLK becomes the synchronous clock. Slave select lines must be implemented separately using Set Port Bit commands. Any slave select lines must be implemented separately using the Set Port Bit command. The data bytes are defined as follows: Byte 1 specifies the settings for the SSPSTAT register as follows: Bit 7: Sample data at end (1) or middle (0) of the clock cycle. Bit 6: Transmit on active to idle (1) or idle to active (0) clock transition (`CKE') Other bits: Must be set to zero Byte 2 specifies the settings for the SSPCON1 register as follows: Bit 5: Enable (1) or disable (0) SPI port. Bit 4: Clock polarity: idle state is at high (1) or low (0) level (`CKP') Bits 1, 0: Clock speed is TMR22 (11), Fo64 (10), Fo16 (01) or Fo4 (00). Other bits: Must be set to zero Examples: 93 80 30 Init fast Mode A (CPOL=1, CPHA = 1) 93 80 20 Init fast Mode B (CPOL=0, CPHA = 1) 93 C0 30 Init fast Mode C (CPOL=1, CPHA = 0) 93 C0 20 Init fast Mode D (CPOL=0, CPHA = 0) In all cases the response is a repeat of the command. UNI/O: (From rev 8) If byte 1, bits 1 and 0 are 10, the port is configured for UNI/O operation. Byte 2 indicates the desired bus frequency as specified as follows: (Bus Freq) = 3 / 2 / (Byte2) p6 22-Nov-10 expandIO-USB HW148-18 www.firmwarefactory.com i.e. be used as the SCIO pin. The other bits should be set to zero.) `Hold mode' is not required of slave devices. (Byte2) = 3 / 2 / (Bus Freq) The lowest permitted value is 0x0F, giving a maximum bus frequency of 93.75kHz for expandIO-USB and 125kHz for USB-XP. Byte 3 bits 7-4 indicate the port (A=0001, B=0010...) and byte 2 bits 2-0 indicate the bit (0-7) to be used as the SCIO pin. Multiple UNI/O buses can be implemented on separate I/O buses. This is useful for avoiding address conflicts, is subject to the restriction that the frequency of all buses will be equal to that specified by the most recent Set Serial command. The TMR1 and CCP1 resources are used. I2C: If byte 1 bit 0 is one, the MSSP port is configured for I2C operation. The SCL pin in the pin diagrams becomes the master clock and the SDA pin becomes the bidirectional data line. Both should be pulled up by 4k7 resistors to Vdd. Byte 1 bit 1 specifies whether the slew rate control is disabled (1, for 100kHz and 1MHz operation) or enabled (0, for 400kHz operation). Byte 2 specifies the clock baud rate, as given by the following formula: FO/(4 * (Byte2 + 1)) Example using expandIO-USB: 93 01 3B 00 Command: I2C on, no slew, 100kHz 93 01 3B 00 Response: OK Execute SPI The identifier EXESPI (0xAF) cycles data through the SPI port. In the command, byte 1 is the number of bytes to be exchanged and bytes 2 onwards are the data to send to the slave device. In the response, byte 1 is the number of bytes that were exchanged and bytes 2 onwards are the data received from the slave device. The EXESPI command and response are not limited to 4 bytes in length. They may use as many bytes in the report as required. If the total length of the command is greater than 4 bytes, they must be the first and only command/response in the report. If byte 5 bit 7 is set, no UNI/O command is sent and only a device poll is performed. If byte 5 bit 7 is clear, Byte 4 is the UNI/O command. Byte 5 bits 5-0 are the number of bytes to write immediately after the UNI/O command. The actual data bytes are given in bytes 7 onwards. Byte 5 bit 6 is 1 if a 600s standby pulse is not required prior to sending the UNI/O command. This bit should only be set if this command immediately follows another to be transmitted to the same device. Byte 6 bits 5-0 are the number of bytes to read after the data bytes have been written. If byte 6 bit 7 is non-zero, the device will enter a 250-bus-clock-cycle device hold state prior to all Master Acknowledge bits, e.g. approx 25ms for 10kHz clock. In the response, byte 1 is a status value as shown in table 6, and bytes 2 onwards are the data received from the slave device. expandIO-USB will acknowledge all but the last data byte received. Interrupts are disabled during the execution of EXEUNIO commands. If byte 6 bit 6 is non-zero then all interrupt-on-change flags (INTxIF / RBIF / RABIF) flags are cleared immediately prior to re-enabling interrupts, and the SCIO line operates as an input when transmission of the command is complete. In order to accommodate interrupt pulses the master will always ensure the SCIO line has been high for at least 600s before starting transmission, and the initial pulse of the start header THDR will be a minimum of15s. If byte 1 bit 3 is non-zero, the start header initial pulse is extended to 100ms. Slaves generate interrupts by pulsing SCIO low. detect these interrupt pulses: To 1. Select an SCIO I/O pin that has interrupt capability. 2. Ensure SCIO has a weak pull-up resistor (e.g. 22k). Example: AF 03 45 67 00 Command: Send 45 67 00 to slave AF 03 00 00 89 Response: Slave sent 00 00 89 (From rev 0009 only.) If byte 1 bit 7 is set, two bytes are appended to the end of the command. These are appended to the end of the response, allowing the PC to easily match command / response pairs. Execute UNI/O The identifier EXEUNIO (0xB0) engages in UNI/O communication with a slave device connected to the SCIO pin indicated by byte 1. (Bits 7-4 indicate the port (A=0001, B=0010...) and bits 2-0 indicate the bit (0-7) to 22-Nov-10 3. Ensure byte 6 bit 6 was set in the preceding EXEUNIO command 4. Clear the interrupt flag and enable the interrupt. 5. When an INTERRUPT (0x95) message is received, poll all devices that could have generated the interrupt to identify which device generated the interrupt. 6. Repeat from step 2. (From revision 0008 only.) p7 Bytes 2 and 3 are the slave device address. For 8-bit addresses, byte 2 should be zero and byte 3 should be the entire slave address. For 12-bit addresses, byte 2 bits 0:3 should be the device high address (i.e. device family), byte 2 bits 4..7 should all be set to `1', and byte 3 should be the device code. expandIO-USB Value 00 03 HW148-18 Table 6. UNI/O status values Meaning Success No slave acknowledge received www.firmwarefactory.com The EXEUNIO command and response are not limited to 4 bytes in length. They may use as many bytes in the report as required. They must be the first and only command/response in the report. General example: B0 15 00 A0 01 02 02 94 64 Command: Send command 01 and then bytes 94 64 to 8-bit slave A0 on SCIO pin RA5, then read two bytes B0 00 12 34 Response: Success, read 12 34 UNI/O serial memory examples: B0 15 00 A0 96 00 00 Write enable command. B0 00 Response: Success B0 15 00 A0 6C 04 00 00 00 56 78 Write 12 34 to address 00 00 B0 00 Response: Success B0 15 00 A0 03 02 02 00 00 Read address 00 00, 2 bytes B0 56 78 Response: Success, read 56 78 HexWax has developed a multicast extension to the UNI/O protocol that allows the same message to be sent to several devices at once, provided the slaves do not respond. For this reason, expandIO-USB will send the entire UNI/O command, even if no slave acknowledges. (From rev 0009 only.) If byte 1 bit 7 is set, two bytes are appended to the end of the command. These are appended to the end of the response, allowing the PC to easily match command / response pairs. Execute I2C (From rev 0006 only.) In a register read operation, the write address is sent and then one or more bytes are written; a restart condition then follows, followed by the slave read address; finally one or more bytes are read. Byte 2 is the write address. Byte 3 is number of bytes to be sent and byte 4 is the number of bytes to then be read. Bytes 5 onwards are the data to write to the slave device. In the response, byte 1 is a status value as shown in table 7, and bytes 2 onwards are the data received from the slave device. A register read consists of a start condition, transmission of the slave address followed by the write data, then reception of the data from the slave, then a stop condition. expandIO-USB will acknowledge all but the last data bytes received. Value 00 01 02 03 Table 7. I2C status values Meaning Success Bus collision occurred Write collision occurred No acknowledge received Many variations on standard I2C communication exist. Contact us if standard write and read operations are not sufficient for your needs. The EXEI2C command and response are not limited to 4 bytes in length. They may use as many bytes in the report as required. They must be the first and only command/response in the report. Examples: A0 00 A2 02 00 00 Command: Write 00 00 to slave A2 A0 00 Response: Success A0 01 A3 02 Command: Read 2 bytes from slave A3 A0 00 12 34 Response: Success, data is 12 34 (Not implemented in 18F2450, 18F4450.) The identifier EXEI2C (0xA0) engages in I2C communication with a slave device connected to SCL / SDA. In the command, byte 1 is 00 for a standard write operation, 01 for a standard read operation and, from rev 0006, 02 for a register read operation. Other values are reserved. Byte 2 is the slave address, which will usually have bit 0 clear for write operations and set for read operations. In a standard write operation, byte 3 is number of bytes to be sent and bytes 4 onwards are the data to send to the slave device. In the response, byte 1 is a status value as shown in table 7. A standard write consists of a start condition, transmission of the slave address followed by the data, then a stop condition. All bytes transmitted should be acknowledged by the slave. In a standard read operation, byte 3 is number of bytes to be read. In the response, byte 1 is a status value as shown in table 7, and bytes 2 onwards are the data received from the slave device. A standard read consists of a start condition, transmission of the slave address followed by reception of the data from the slave, then a stop condition. expandIO-USB will acknowledge all but the last data bytes received. p8 22-Nov-10 expandIO-USB A0 02 A2 01 02 55 Command: Write byte `55' to slave A3 then read 2 bytes A0 00 12 34 Response: Success, data is 12 34 (From rev 0009 only.) If byte 1 bit 7 is set, two bytes are appended to the end of the command. These are appended to the end of the response, allowing the PC to easily match command / response pairs. Interrupt Event The identifier INTERRUPT (0x95) reports an interrupt event. It has no payload and is sent unprompted when one or more interrupt events have occurred. Interrupts occur when an interrupt is enabled (xxxIE = 1) and flagged (xxxIF = 1). In this event, expandIO-USB disables the interrupt (xxxIE = 0) and generates an INTERRUPT report. It is the responsibility of the host application to determine the cause of the interrupt by inspecting the interrupt flags, clearing the flag and resetting the interrupt enable bit. To set up an interrupt, clear the interrupt flag and set the interrupt enable using the Set Register Bit commands. HW148-18 www.firmwarefactory.com The interrupts should be configured as high priority, as they are by default. Example using interrupt-on-change: 98 81 00 00 98 81 3F 00 9B F2 00 00 9B F2 00 00 9B F2 03 01 9B F2 03 01 95 00 00 00 9B F2 00 00 9B F2 00 00 9B F2 03 01 9B F2 03 01 95 00 00 00 Command: Read Port B (Clears any mismatch condition - refer to base microcontroller data sheet) Response: Port B is 0x3F Command: Clear RBIF Response: Cleared RBIF Command: Set RBIE Response: Set RBIE Response - An interrupt occurred Command: Clear RBIF Response: Cleared RBIF Command: Re-Set RBIE Response: Re-Set RBIE Response - An interrupt occurred AA 03 73 00 Response - Port C changed to 73 when Port B bit 3 high AA 00 00 00 Command - Stop scanning AA 00 00 00 Response - Confirm command A typical matrix scan circuit is shown in figure 6. If it is necessary to correctly detect if more than one key is pressed at a time, line isolation diodes as shown in figure 7 will be required. To avoid the need for switch de-bouncing, scans are only made every 25 ms. Vss . Figure 6 In the response, byte 3 will be the number of milliseconds remaining before the timeout would have occurred, or 0 if it did occur. The timeout is required, as USB commands are not processed during wait periods. Example: A9 81 83 FF Command - wait for Port B bit 3 to set or 255ms to elapse A9 81 83 00 Response - timed out Matrix Scan The identifier SCANMATRIX (0xAA) configures a keyboard matrix scan on two ports. Byte 1 bits 4-7 indicates the scan port and byte 1 bits 0-3 indicate the data port (Disable=0000, A=0001, B=0010... for both). Byte 2 is a mask which indicates which bits to enable on the scan port. Byte 3 is a mask which indicates which bits to enable on the data port. Only one scan operation be in progress at any one time. Once this command is sent, all enabled pins on the first port are tri-stated. When expandIO-USB is idle, it will scan these outputs by setting them one by one to a high output state and observing the state of the input port. If the state of the input port (for a given scan line on the output port) has changed since the last scan, a SCANMATRIX response will be generated unprompted. Byte 1 will indicate the output port bit and byte 2 will indicate the input port value. AA 23 07 FF Command - Set Port B bits 0-3 out, all of Port C in AA 23 07 FF Response - Confirm command AA 03 7B 00 Response - Port C changed to 7B when Port B bit 3 high 22-Nov-10 expandIO-USB . . . . . Input lines . Vss . The identifier WAIT (0xA9) waits until a register bit changes or a timeout occurs. Byte 1 indicates the register and byte 2 bits 0-2 indicates the bit (0-7). Byte 2 bit 7 is 0 for wait until clear or 1 for wait until set. Byte 3 is the timeout in milliseconds. Actual timeout might take slightly more time than specified, but never less. . 22k Scan lines Wait p9 . . Figure 7 . . . . . 22k . . . . Input lines Scan lines Multiplex Output The identifier CAMULTIPLEX (0xAB) and CCMULTIPLEX (0xAE) configure a display multiplex on two ports. Byte 1 bits 4-7 indicates the scan port and byte 1 bits 0-3 indicate the data port (Disable=0000, A=0001, B=0010... for both). Byte 2 is a mask which indicates which bits to enable on the scan port. Byte 3 is a mask which indicates which bits to enable on the data port. The identifier MPXDATA (0xAC) specifies the data to output on the data port for each scan state. Byte 1 indicates which scan bit (0-7) the data is for and byte 2 indicates the value to output on the data port when that scan bit is active. Inactive bits on both ports are tri-state. Byte 3 is the brightness, expressed as a duty cycle from 00 (off) to 255 (fully on). When setting brightness levels, bear in mind that perceived brightness is logarithmic. If the CAMULTIPLEX command is specified, the scan bit is active high and the data bits are active low, suitable for common anode displays. If the CCMULTIPLEX command is specified, the scan bit is active low and the data bits are active high, suitable for common cathode displays. Only one multiplex operation be in progress at any one time. Once this command is sent, the scan port pins will be activated for exactly equal periods (~1ms) and at the same time the data output port will output the data specified by the MPXDATA commands. Timer0 is used to implement the multiplex function AC 02 45 FF Command - When scan bit 2 high, Output 45 on Port C's data pits, full brightness HW148-18 www.firmwarefactory.com AC 02 45 FF Response - Command acknowledge AC 03 46 FF Command - When scan bit 3 high, Output 46 on Port C's data pits, full brightness AC 03 46 FF Response - Command acknowledge AC 04 47 80 Command - When scan bit 4 high, Output 47 on Port C's data pits, half brightness AC 94 47 80 Response - Command acknowledge AB 23 1C FF Command - Set Port B bits 2-4 scan, Port C all bits data AB 08 7B 00 Response - Command acknowledge (Scans bits 2, 3 and 4 of Port B while outputting 45-46-47 on Port C. Send further MPXDATA commands to change displayed data) AB 00 00 00 Command - Stop scanning AB 00 00 00 Response - Confirm command A typical display multiplex scan circuit is shown in figure 8. The value of the resistors on the data lines should be selected as recommended by the display manufacturer, bearing in mind that if there are n scan lines then each LED will have a maximum on-time duty cycle of 1/n. Segments a-g, DP Data lines 100R . . . COM COM COM Figure 8 Scan lines Stream Data expandIO-USB will never be so busy streaming data that it will not be able to respond to new commands. Example: 96 16 00 00* 96 16 01 23 96 15 00 00* 96 15 02 4A Command - Get AN6 using Vref+ Response: AN6 = 0x123 Command - Get AN5 using Vref+ Response: AN5 = 0x24A AD 5A C3 00 Command - repeat the report every ~6.27ms (see table 8) Response: Acknowledge command Response: Sequence number 0x0001 Response: AN6 = 0x122 Response: AN5 = 0x2C3 Response: Sequence number 0x0002 Response: AN6 = 0x121 Response: AN5 = 0x2C4 Command - Stop streaming * These commands must be in the same report. AD 5A C3 00 AD 00 01 00 96 16 01 22 96 15 02 C3 AD 00 02 00 96 16 01 21 96 15 02 C4 AD 00 00 00 Note: The previous report is only stored if streaming is not in process. To change the stream commands, stop streaming first, then send the new report to be streamed, then start streaming again. Get Firmware ID The identifier GETFWID (0x94) retrieves the firmware version number. In the response the device is in byte 1 (0x14 for 14K50, 0x25 for 2455, etc) and a version number is in bytes 2 (MSB) and 3 (LSB). Example: The identifier STREAM (0xAD) repeatedly executes the commands sent in the previous report. The stream command must be the first command in the report. Bytes 1 and 2 indicate repeat interval as shown in table 8. The Timer2 is used for triggering the stream. To stop streaming, send a stream command with Byte 1 equal to zero. Each time the stream is triggered by the timer, expandIO-USB sends a STREAM (0xB4) response. Bytes 1 (MSB) and 2 (LSB) will contain a sequence number which will increment by one each time a stream response is sent (and rolling over from 0xFFFF to 0x0000). The requested commands will then be executed and responses relating to those commands will be sent. Table 8. Stream repeat interval Byte 2 Repeat Interval Byte 1, Byte 1, bits 6-3 bits 1-0 01 x y 2*y*(x+1) / 3 s 10 x y 8*y*(x+1) / 3 s Example: Byte 1 = 01011010, Byte 2 = 11000100, low speed device Formula is 8*y*(x+1) / 3 s, x is 11 decimal, y is 196 decimal Repeat interval is 6.272ms (Slowest possible is 10.88ms) 94 00 00 00 94 14 00 01 Command - Get Firmware ID Response - 14K50 v0001 Customization The product can be customized in one of three ways: 1. Using the HIDconfig.exe application (figure 9) in the development kit. This application makes it very easy to copy the configuration from an existing product to a new product and is suitable for in-factory use. (It cannot be used if you change the Vendor ID and / Product ID.) 2. By requesting the custom settings to be supplied pre-programmed when buying preprogrammed chips (5K units minimum). 3. Using customization Documentation on these available on request. commands. commands is The stream rate will only be achieved if the commands requested can be executed at the rate requested. Otherwise, the rate will be the maximum achievable rate. p10 22-Nov-10 expandIO-USB HW148-18 www.firmwarefactory.com In addition, the prototyping area on the left may be used to add components to which the expandIO-USB will interface. The printed circuit board integrates an edge connector of USB Type A format. This may be plugged into a USB extension cable. The HIDconfig.exe application can be used to discover and test the evaluation circuit prior to writing a software application to do the task. Figure 9. HIDconfig.exe application Delivery and Programming Table 10. Evaluation Board minimum bill of materials Label Component U2 expandIO-USB-28-FS-DIL D2 Wire link C4 100nF capacitor C7 10uF capacitor C8 470nF capacitor X1 12MHz parallel cut crystal C2, C3 22pF capacitor R2 22k resistor LED1, LED2 Light emitting diode 5mm Additional components may be added for a more complete evaluation In high volumes (5K+), expandIO-USB is available reeled with your custom settings preloaded. The devices listed in table 9 are commonly stocked by distributors. Table 9. Commonly stocked part numbers Part number MCU USB Speed Package USB-expandIO-DIL 18LF2455 Full DIL-28 USB-expandIO-PT 18LF4455 Full TQFP-44 USB-expandIO-SS 18F14K50 Full SSOP-20 USB-expandIO-SS may be supplied with an ID label, or it may be identified with a red mark on the package. Programming expandIO-USB expandIO-USB may be programmed in-circuit provided the programming signals PGC, PGD and Vpp are protected against contention. In particular, note that the Vpp line is subject to a voltage of up to 13V during programming. Nothing else should be connected to this input except via a 22k pull-up resistor. Since the programming time is fast, no programming socket is required for the TEAclipper. It may be leaned against five plate-through holes as described in figure 10. In-circuit programming connections of some form should always be provided, even if the device is supplied pre-loaded, in order to facilitate firmware upgrades. Pin 1 indicated by square pad 2.54mm spacing Figure 11. USB Products Eval Board (Additional components added compared to table 8.) Licensing This firmware is copyright Firmware Factory Ltd and may only be used with permission. Licenses may be purchased from HexWax Ltd. For preprogrammed reels, contact Firmware Factory Ltd. Development Kit A firmware development kit is available for download from www.hexwax.com containing the following files: Base controller data sheets ((c) Microchip Technology Inc) USB 2.0 Specification ((c) HP / Intel / Lucent / Microsoft / NEC / Philips 2000) UNI/OTM Bus Specification DS22076 ((c) Microchip Technology Inc) HIDconfig.exe for in-factory customization of expandIO-USB devices via the USB port. 1mm hole dia Vss Vpp PGC PGD Vdd Figure 10. Recommended TEAclipper PCB connector Evaluation Board expandIO-USB may be evaluated with the Firmware Factory USB Products Eval Board (figure 11). The components which must be fitted are shown in table 10. p11 22-Nov-10 expandIO-USB HW148-18 www.firmwarefactory.com AN1149 Designing a Li-Ion charger system... for design examples on charging batteries from USB power ((c) Microchip Technology Inc 2006) usb-win.c and usb-win.h, sample HID code for Windows. Additionally the files setupapi.h, hidsdi.h, hidpi.h, setupapi.lib and hid.lib are provided, which must be included in the application. FwFhid.dll dynamic link library and Visual Basic example FwFhidDLLExample.xls. Warranty The warranty and liability provisions for this pre-loaded software product follow software industry conventions. Please refer to www.hexwax.com for a complete warranty statement. Firmware Factory Ltd 2 Marshall St, 3rd Floor London W1F 9BB, UK sales@firmwarefactory.com support@firmwarefactory.com p12 22-Nov-10 expandIO-USB HW148-18 www.firmwarefactory.com Appendix A: Register Maps This table is provided as a quick reference. Directly accessing registers requires in-depth knowledge of the base microcontroller. Refer to the base microcontroller data sheet for details. The following registers are not accessible: TOSU, TOSH, TOSL, STKPTR, PCLATU, PCLATH, PCLATL, TBLPTRU, TBLPTRH, TBLPTRL, TABLAT, PRODH, PRODL, INDF0, POSTINC0, POSTDEC0, PREINC0, PLUSW0, FSR0H, FSR0L, WREG, INDF1, POSTINC1, POSTDEC1, PREINC1, PLUSW1, FSR1H, FSR1L, INDF2, POSTINC2, POSTDEC2, PREINC2, PLUSW2, FSR2H, FSR2L, BSR, OSCCON, OSCCON2, OSCTUNE, WDTCON, EECON1, EECON2, EEADR, EEDATA, OSCTUNE, USB registers and general-purpose file registers. ECCP registers are listed as CCP. PIC18F14K50 Register Command Byte1 ADCON0 ADCON1 ADCON2 ADRESH ADRESL ANSEL ANSELH BAUDCON CCP1CON CCPR1H CCPR1L CM1CON0 CM2CON1 CM2CON0 ECCP1AS INTCON INTCON2 INTCON3 IOCA IOCB IPR1 IPR2 LATA LATB LATC PIE1 PIE2 PIR1 PIR2 PORTA PORTB PORTC PR2 PSTRCON PWM1CON RCON RCREG REFCON0 REFCON1 REFCON2 RCSTA SLRCON SPBRG SPBRGH SRCON0 SRCON1 SSPADD SSPBUF SSPCON1 0xC2 0xC1 0XC0 0xC4 0xC3 0x7E 0x7F 0xB8 0xBD 0xBF 0xBE 0x6D 0x6B 0x6C 0xB6 0xF2 0xF1 0xF0 0x79 0x7A 0x9F 0xA2 0x89 0x8A 0x8B 0x9D 0xA0 0x9E 0xA1 0x80 0x81 0x82 0xCB 0xB9 0xB7 0xD0 0xAE 0xBA 0xBB 0xBC 0xAB 0x76 0xAF 0xB0 0x68 0x69 0xC8 0xC9 0xC6 p13 Description / Bitmap** 7 - - ADFM 6 - - - 5 CHS3 4 CHS2 ACQT2 ACQT1 3 CHS1 PVCFG1 ACQT0 2 CHS0 PVCFG0 ADCS2 1 GO/DONE# NVCFG1 ADCS1 0 ADON NVCFG0 ADCS0 ANS10 ANS9 ANS8 - CCP1M2 WUE CCP1M1 ABDEN CCP1M0 C1R C2HYS C2R PSSAC0 TMR0F TMR0IP - C1CH1 C1SYNC C2CH1 PSSBD1 INT0IF - INT2IF C1CH0 C2CYNC C2CH0 PSSBD0 RABIF RABIP INT1IF CCP1IP USBIP - - LATC2 CCP1IE USBIE CCP1IF USBIF - - PORTC2 IOCA1 TMR2IP TMR3IP - - LATC1 TMR2IE TMR3IE TMR2IF TMR3IF - - PORTC1 IOCA0 TMR1IP - - PORTC0 STRC PDC2 PD# STRB PDC1 POR# STRA PDC0 BOR# DAC1R1 OERR SLRB D1NSS DAC1R0 RX9D SLRA SRPS SRRC2E SRPR SRRC1E SSPM1 SSPM0 A/D result ANS7 ABDOVF P1M1 ANS6 RCIDL P1M0 ANS5 DTRXP DC1B1 ANS4 SCKP DC1B0 ANS11 ANS3 BRG16 CCP1M3 Capture / compare PWM 1 registers C1ON C1OUT C1OE C1POL C1SP MC1OUT MC2OUT C1RSEL C2RSEL C1HYS C2ON C2OUT C2OE C2POL C2SP ECCPASE ECCPAS2 ECCPAS1 ECCPAS0 PSSAC1 GIE(H) PEIE TMR0IE INT0IE RABIE RABPU# INTEDG0 INTEDG1 INTEDG2 - INT2IP INT1IP - INT2IE INT1IE IOCB7 IOCB6 IOCB5 IOCB4 IOCA5 IOCA4 IOCA3 ADIP RCIP TXIP SSPIP OSCFIP C1IP C2IP EEIP BCLIP - - LATA5 LATA4 - LATB7 LATB6 LATB5 LATB4 - LATC7 LATC6 LATC5 LATC4 LATC3 ADIE RCIE TXIE SSPIE OSCFIE C1IE C2IE EEIE BCLIE ADIF RCIF TXIF SSPIF OSCFIF C1IF C2IF EEIF BCLIF - - PORTA5 PORTA4 - PORTB7 PORTB6 PORTB5 PORTB4 - PORTC7 PORTC6 PORTC5 PORTC4 PORTC3 Timer2 period STRSYNC STRD PRSEN PDC6 PDC5 PDC4 PDC3 IPEN SBOREN- RI# TO# UART receive register FVR1EN FVR1ST FVR1S1 FVR1S0 TSEN D1EN D1LPS DAC1OE D1PSS1 DAC1R4 DAC1R3 SPEN RX9 SREN CREN ADDEN SREN SRSPE SRCLK2 SRSCKE WCOL SSPOV 22-Nov-10 TSRS D1PSS0 DAC1R2 FERR SLRC UART baud rate generator low byte UART baud rate generator high byte SRCLK1 SRCLK0 SRQEN SRNQEN SRSC2E SRSC1E SRRCKE Synchronous serial port address / baud / mask Synchronous serial port receive / transmit buffer SSPEN CKP SSPM3 SSPM2 expandIO-USB HW148-18 - - LATC0 TMR1IE TMR1IF www.firmwarefactory.com Register Command Byte1 SSPCON2 SSPMASK SSPSTAT STATUS T0CON T1CON T2CON T3CON TMR0H TMR0L TMR1H TMR1L TMR2 TMR3H TMR3L TRISA TRISB TRISC TXREG TXSTA WPUA WPUB 0xC5 0x6F 0xC7 0xD8 0xD5 0xCD 0xCA 0xB1 0xD7 0xD6 0xCF 0xCE 0xCC 0xB3 0xB2 0x92 0x93 0x94 0xAD 0xAC 0x77 0x78 Description / Bitmap** 7 GCEN MSK7 SMP - TMR0ON RD16 - RD16 6 ACKSTAT MSK6 CKE - T08BIT T1RUN T2OUTPS3 5 ACKDT MSK5 D/A# - T0CS T1CKPS1 T2OUTPS2 T3CKPS1 4 ACKEN MSK4 P N T0SE T1CKPS0 T2OUTPS1 T3CKPS0 3 RCEN MSK3 S OV PSA T1OSCEN T2OUTPS0 T3CCP1 2 PEN MSK2 R/W# Z T0PS2 T1SYNC# TMR2ON T3SYNC# 1 RSEN MSK1 UA DC T0PS1 TMR1CS T2CKPS1 TMR3CS 0 SEN MSK0 BF C T0PS0 TMR1ON T2CKPS0 TMR3ON Timer0 registers Timer1 registers Timer2 register Timer3 registers - TRISB7 TRISC7 - TRISB6 TRISC6 TRISA5 TRISB5 TRISC5 CSRC TX9 WPUB7 WPUB6 TXEN WPUA5 WPUB5 TRISA4 TRISB4 TRISC4 TRISC3 TRISC2 TRISC1 TRISC0 UART transmit register SYNC SENDB BRGH TRMT TX9D WPUA4 WPUA3 WPUB4 **Refer to base microcontroller data sheet for details Register Command Byte1 2450* 4450* 2455* 4455* PIC18F2450 / PIC18F2455 / PIC18F4450 / PIC18F4455 ADCON0 ADCON1 ADCON2 ADRESH ADRESL BAUDCON CCP1AS CCP1CON CCP1DEL CCP2CON CCPR1H CCPR1L CCPR2H CCPR2L CMCON CVRCON HLVDCON INTCON INTCON2 INTCON3 IPR1 IPR2 LATA LATB LATC LATD LATE PIE1 PIE2 PIR1 PIR2 PORTA PORTB 0xC2 0xC1 0XC0 0xC4 0xC3 0xB8 0xB7 0xBD 0xB6 0xBA 0xBF 0xBE 0xBC 0xBB 0xB4 0xB5 0xD2 0xF2 0xF1 0xF0 0x9F 0xA2 0x89 0x8A 0x8B 0x8C 0x8D 0x9D 0xA0 0x9E 0xA1 0x80 0x81 p14 22-Nov-10 Description / Bitmap** 7 - - ADFM 6 - - - 5 CHS3 VCFG1 ACQT2 4 CHS2 VCFG0 ACQT1 3 CHS1 PCGF3 ACQT0 2 1 0 CHS0 GO/DONE# ADON PCGF2 PCGF1 PCGF0 ADCS2 ADCS1 ADCS0 A/D result ABDOVF RCIDL DTRXP SCKP BRG16 CCP1ASE CCP1AS2 CCP1AS1 CCP1AS0 PSS1AC1 P1M1 P1M0 DC1B1 DC1B0 CCP1M3 P1RSEN P1DC6 P1DC5 P1DC4 P1DC3 P2M1 P2M0 DC2B1 DC2B0 CCP2M3 - PSS1AC0 CCP1M2 P1DC2 CCP2M2 WUE PSS1BD1 CCP1M1 P1DC1 CCP2M1 ABDEN PSS1BD0 CCP1M0 P1DC0 CCP2M0 CM1 CVR1 HLVDL1 INT0IF - INT2IF TMR2IP TMR3IP LATA1 LATB1 LATC1 LATD1 LATE1 TMR2IE TMR3IE TMR2IF TMR3IF PORTA1 PORTB1 CM0 CVR0 HLVDL0 RBIF RBIP INT1IF TMR1IP CCP2IP LATA0 LATB0 LATC0 LATD0 LATE0 TMR1IE CCP2IE TMR1IF CCP2IF PORTA0 PORTB0 Capture / compare PWM 1 registers Capture / compare PWM 2 registers C2OUT CVREN VDIRMAG GIE(H) RBPU# INT2IP SPPIP OSCFIP - LATB7 LATC7 LATD7 - PMPIE OSCFIE SPPIP OSCFIF - PORTB7 C1OUT CVROE - PEIE INTEDG0 INT1IP ADIP CMIP - LATB6 LATC6 LATD6 - ADIE CM2IE ADIF CMIF - PORTB6 C2INV CVRR IRVST TMR0IE INTEDG1 - RCIP USBIP LATA5 LATB5 - LATD5 - RCIE USBIE RCIF USBIF PORTA5 PORTB5 expandIO-USB C1INV CVRSS HLVDEN INT0IE INTEDG2 INT2IE TXIP EEIP LATA4 LATB4 - LATD4 - TXIE EEIE TXIF EEIF PORTA4 PORTB4 CIS CVR3 HLVDL3 RBIE - INT1IE SSPIP BCLIP LATA3 LATB3 LATC3 LATD3 - SSPIE BCLIE SSPIF BCLIF PORTA3 PORTB3 HW148-18 CM2 CVR2 HLVDL2 TMR0F TMR0IP - CCP1IP HLVDIP LATA2 LATB2 LATC2 LATD2 LATE2 CCP1IE HLVDIE CCP1IF HLVDIF PORTA2 PORTB2 www.firmwarefactory.com Register Command Byte1 2450* 4450* 2455* 4455* PORTC PORTD PORTE PR2 RCON RCREG RCSTA SPBRG SPBRGH SPPCFG SPPCON SPPDATA SPPEPS SSPADD SSPBUF SSPCON1 SSPCON2 SSPSTAT STATUS T0CON T1CON T2CON T3CON TMR0H TMR0L TMR1H TMR1L TMR2 TMR3H TMR3L TRISA TRISB TRISC TRISD TRISE TXREG TXSTA 0x82 0x83 0x84 0xCB 0xD0 0xAE 0xAB 0xAF 0xB0 0x63 0x65 0x62 0x64 0xC8 0xC9 0xC6 0xC5 0xC7 0xD8 0xD5 0xCD 0xCA 0xB1 0xD7 0xD6 0xCF 0xCE 0xCC 0xB3 0xB2 0x92 0x93 0x94 0x95 0x96 0xAD 0xAC Description / Bitmap** 7 6 5 4 3 2 1 PORTC7 PORTC6 - - PORTC3 PORTC2 PORTC1 PORTD7 PORTD6 PORTD5 PORTD4 PORTD3 PORTD2 PORTD1 - - - - - PORTE2 PORTE1 Timer2 period IPEN - CM# RI# TO# PD# POR# UART receive register SPEN RX9 SREN CREN ADDEN FERR OERR UART baud rate generator low byte UART baud rate generator high byte CLKCFG1 CLKCFG0 CSEN CLK1EN WS3 WS2 WS1 - - - - - - SPPOWN DATA7 DATA6 DATA5 DATA4 DATA3 DATA2 DATA1 RDSPP WRSPP - SPPBUSY ADDR3 ADDR2 ADDR1 Synchronous serial port address / baud / mask Synchronous serial port receive / transmit buffer WCOL SSPOV SSPEN CKP SSPM3 SSPM2 SSPM1 GCEN ACKSTAT ACKDT ACKEN RCEN PEN RSEN SMP CKE D/A# P S R/W# UA - - - N OV Z DC TMR0ON T08BIT T0CS T0SE PSA T0PS2 T0PS1 RD16 T1RUN T1CKPS1 T1CKPS0 T1OSCEN T1SYNC# TMR1CS - T2OUTPS3 T2OUTPS2 T2OUTPS1 T2OUTPS0 TMR2ON T2CKPS1 RD16 T3RUN T3CKPS1 T3CKPS0 T3OSCEN T3SYNC# TMR3CS 0 PORTC0 PORTD0 PORTE0 BOR# RX9D WS0 SPPEN DATA0 ADDR0 SSPM0 SEN BF C T0PS0 TMR1ON T2CKPS0 TMR3ON Timer0 registers Timer1 registers Timer2 register Timer3 registers - - TRISA5 TRISA4 TRISA3 TRISA2 TRISA1 TRISA0 TRISB7 TRISB6 TRISB5 TRISB4 TRISB3 TRISB2 TRISB1 TRISB0 TRISC7 TRISC6 - - TRISC3 TRISC2 TRISC1 TRISC0 TRISD7 TRISD6 TRISD5 TRISD4 TRISD3 TRISD2 TRISD1 TRISD0 - - - - - TRISE2 TRISE1 TRISE0 UART transmit register CSRC TX9 TXEN SYNC SENDB BRGH TRMT TX9D * =Implemented, =Not implemented **Refer to base microcontroller data sheet for details Appendix B: Device Pin-Outs Device pin-outs are shown in the accompanying PDF file "expandIO-USB Pinouts HW148B". These pages are coped from the base controller data sheets and are copyright Microchip Technology Ltd. p15 22-Nov-10 expandIO-USB HW148-18 www.firmwarefactory.com