TITAN IR-200S Programming Note



The IR-200S IR-Dongle is programmed by sending a Control Byte via the UART Controller. For proper operation, the UART must be programmed as 8-bit data word, no parity and 1 stop bit. To correctly initialize the IR-200S, you should first RESET, and then PROGRAM to 9600 baud, then go to NORMAL operation.

Note: The SPACE state means "1" programmed, the MARK state means "0".

Function Operation
Power Off Keep both RTS & DTR at MARK state for 100 msec
Reset Sequence:
  1. Set RTS and DTR both to Mark state, wait 100 ms ( power off the IR-200S )
  2. Set RTS to SPACE state ( the signal on RS-232 is on its POSITIVE voltage)
  3. Set DTR to MARK state, wait at least 1 ms ( the signal is NEGATIVE volt.)
  4. Set DTR to SPACE state, wait at least 50 us for further operation
Normal Keep both RTS & DTR at SPACE state for normal operation
Programming Sequence:
  1. Set DTR to SPACE state 
  2. Set RTS to MARK state, wait at least 7 us
  3. Send Control Byte to the IR-200S through TXD to set new baud rate, etc (See programming note above for transfer baud rate)
  4. Wait until the stop bit of Control Byte is sent (for 9600 baud rate, it takes about 100 msec)
  5. Set RTS to SPACE state (return to NORMAL Operation)
  6. Wait at least 50 us, new setting (baud rate, etc) takes effect here after

Programming Sequence

  1. Under the current baud rate, execute the RESET Operation, then change the RS-232 port baud rate to 9600
  2. Under baud rate 9600, execute the PROGRAMMING operation, after the programming, the IR-200S should enter the NORMAL operation.
  3. Set the RS-232 port baud rate to the new setting which programmed to the IR-200S

Control Byte Information

BIT7 6 5 4 3 2 1 BIT0
0 0 0 PW B3 B2 B1 B0

Where

PW:  IrDA pulse select
1 = 1.6 us output pulse ( preferred setting )
0 = 3/16 bit time pulse
B3..B0: Baud rate select (values other than below are undefined)
B3 B2 B1 B0 HEX Baud Rate
0 0 0 0 0 115.2 K
0 0 0 1 1 57.6 K
0 0 1 0 2 38.4 K
0 0 1 1 3 19.2 K
0 1 0 0 4 9.6 K

Example Code:

    void delay(int count)
    {
    	while(count-- > 0)  outp(0x80,0);
    }

    void IR_reset()
    {
    	outp(comport+4,0x03);       /* normal operation */
    	delay(10000);
    	outp(comport+4,0x02);       /* -DTR low -> reset PIC */
    	delay(200);
    	outp(comport+4,0x03);       /* back to normal operation */
    	delay(20);
    }
    
    IR_ctlbyte(char ctlbyte)
    {
    	outp(comport+4,0x01);       /* -RTS low -> send control byte */
    	delay(10);
    	outp(comport,ctlbyte);
    	delay(2000);
    	outp(comport+4,0x03);       /* back to normal operation */
    }
    
    void setbaud(int baud)
    {
    	outp(comport+3,0x83);       /* LCR, select DLAB */
    	outp(comport+0,baud);       /* DLAB LSB */
    	outp(comport+1,0x00);       /* DLAB MSB, always be 0 */
    	outp(comport+3,0x03);       /* LCR, NP-1S-8D format */
    	outp(comport+2,0x00);       /* FCR */
    	outp(comport+1,0x00);       /* IER */
    }
    
    int     baud_div[] = {1,2,3,6,12};      /* UART DLAB divider */
    char    ctlbyte[]={0x10,0x11,0x12,0x13,0x14}; 
    /*
    see control byte information above for control byte definition
    Control byte   BaudRate
    0x10           115200bps
    0x11           57600 bps
    0x12           38400 bps
    0x13           19200 bps
    0x14            9600 bps
    */
    
    void main(void)
    {
    	/* Reset IR-200S IR_Dongle  & Set UART to 115.2K baud */
    	IR_reset();
    	setbaud(baud_div[4]);
    	IR_ctlbyte(ctlbyte[0]);
    	setbaud(baud_div[ctlbyte]);
    	inp(comport);
    }