Features

Applications

Programmable

EEProm stores commands and settings

  1.  
  2. Description
  3. BL233 is a simple and effective way to use I2C devices with any computer and OS. Fully built RS232/USB adaptors are available.

    Table Of Contents

    Features *

    Applications *

    Programmable *

    1 Description *

    2 Table 1: BL233 Pinout Description *

    3 I2C Busses *

    3.1 Bit Timing *

    3.2 SCL Stretch *

    3.3 Four Wire Bus *

    3.4 Fast Mode *

    3.5 Multimaster Arbitration *

    4 Table 2: Command Character List *

    5 Command Format *

    5.1 A simple I2C Transaction *

    5.2 Stop *

    5.3 Reading I2C *

    5.3.1 Reading an indeterminate number of bytes: Pascal Strings *

    5.4 10 Bit Addresses *

    5.5 R and W: Fast Read/Write Commands *

    5.6 Selecting the I2C Bus *

    5.7 Delaying *

    5.8 Pause Command for Timing Critical Sequences *

    5.9 I2C Acknowledge *

    5.9.1 Writing *

    5.9.2 Reading *

    6 Status and Control Registers *

    6.1 Setting Control Register and Bus Timing *

    6.2 Querying Status Register *

    6.3 Interrupt Pin *

    6.4 Return a Char *

    7 Message Numbers *

    8 Direct Pin I/O *

    8.1.1 Pin Timing *

    9 SPI *

    9.1 CS/Strobe Pins *

    9.2 Short Data *

    9.3 Bidirectional (simultaeneous) Write/Read *

    9.4 SPI Clock Polarity *

    9.5 M5451 *

    10 1Wire Bus *

    10.1 Pins *

    10.2 Software *

    11 EEProm Memory *

    11.1 Table 3: EEProm Memory Map *

    11.2 Macros *

    11.3 A Macro for combined 8 switches + 8 Leds board *

    11.4 A simple "program" *

    11.5 Writing the EEProm *

    11.5.1 Write Protecting the EEProm *

    11.6 Dumping the EEProm *

    12 Serial Comms *

    12.1 EOL and Separator Chars *

    12.2 Data Format *

    12.3 Baud Rate *

    12.3.1 Special Pins Mode *

    12.4 Max Baud Rate and Speed *

    12.4.1 PC Serial Port Latency *

    12.4.2 RS232 Drivers *

    12.5 Serial Buffer Size *

    12.6 Handshaking *

    12.7 Table 4: Serial Initalisation Registers in EEProm *

    12.8 USB *

    13 Oscillator *

    13.1 Timer *

    14 Watchdog *

    14.1 Uses *

    15 Reset *

    16 Sleep Mode *

    17 I2C Bus Connectors and Pinouts *

    18 Example Applications *

    18.1 I2C-2-PC: Dual Interface USB & RS232 to I2C Adaptor *

    18.2 Simple I2C to RS232 Adaptor *

    18.3 Simple Data logger with no PC Software *

    18.4 Isolating an I2C Bus *

    18.5 RS232 to LCD Module adaptor *

    18.6 Huge RS232 Parallel Port *

    18.7 Hardware Watchdog for Network or Server *

    18.7.1 Circuit *

    18.7.2 Operation *

    18.7.3 Code *

    19 Migration from BL232 A, B *

    20 Ordering Information *

    21 Co-operation *

  4. Table 1: BL233 Pinout Description
  5. Name DIP Pin # SSOP Pin # I/O/P Type Buffer Type User Pin Description Bit #
    SCL1 17 19 I/oc ST I/0 I2C Bus #1 P0
    SDA1 18 20 I/oc ST I/0 I2C Bus #1 P1
    SCL2 1 1 I/oc ST I/0 I2C Bus #2 P2
    SDA2 2 2 I/oc ST I/0 I2C Bus #2 P3
    SDA4 3 3 In ST I/oc I2C#4, SPI#2 CS pin, 1Wire P4
    _Reset_ 4 4 In ST In    
    Vss 5 5,6          
    Int 6 7 In ST I/0 0=interrupt  
    RXD 7 8 In ST -- RS232 data IN, Connect to PC TXD  
    TXD 8 9 Out   -- RS232 data Out, Connect to PC RXD  
    CTS 9 10 Out   I/0 Connect to PC CTS, Tells PC to send  
    RTS 10 11 IN TTL I/0 Connect to PC RTS, PC controls me.  
    SCL4 11 12 I/O TTL I/0 I2C#4, SPI#3 CS pin, 1Wire P5
    SCL3 12 13   TTL I/0 I2C Bus #3 P6
    SDA3 13 14   TTL I/0 I2C Bus #3 P7
    VDD 14 15,16          
    X2 Out 15 17       Crystal / Oscillator Out  
    X1 In 16 18       Crystal / Oscillator In (14.7456)  
  6. I2C Busses

The BL233 supports up to 4 physical 2 wire I2C Busses. (1-4)

Two operate with Schmitt-CMOS levels, and 2 with TTL levels.

Only one bus can be active at one time. The bus will be put into Stop (P) state before selecting the new bus.

Bus numbers above 4 are logical busses, ie they map to the same pins as another bus, or work differently

SPI works on I2C busses, by setting the SPI mode. All busses operate in an opencollector fashion, and expect external pullups.

 

    1. Bit Timing
    2. Timing complies with the specs for standard 100kHz I2C. To slow the bus you may load another value into the I2Ctiming byte.

      see 6.1:Setting Control Register and Bus Timing

    3. SCL Stretch
    4. SCL Stretch is supported. It is implemented on a bit-by-bit basis.

      It is tested at the start of a cycle, or S or P states.

      Why test at the Start when the slave asserts stretch at the end of a cycle?

      The stretch is asserted by the slave after the ACK, however it does not impact the master until it attempts to begin the next byte/S/P. By testing at the beginning of the next byte, most SCL stretches will have no affect on throughput.

      SCL Stretch should be asserted for <10ms. Clock stretch will timeout after approx. 218/fXtal secs. (17ms @ 14.7MHz). A clock stretch timeout is flagged in the status register.

    5. Four Wire Bus
    6. It is significantly easier to isolate a bus when the transmit and receive are split. A 4 wire logical bus can be used where galvanic isolation is required.

      For most applications where SCL stretch is not used, 2 isolators are needed from the BL233, and only a single return SDA isolator. In this case a half-split bus can be used.

      You can use a single IL716 magnetic coupler from NVE.

      Note that it is often easier to isolate the RS232 bus.

    7. Fast Mode
    8. Busses can also be operated in Fast Mode (400kb). This improves throughput somewhat when high baud rates are used.
    9. Multimaster Arbitration

There is no support for multimaster. BL233 assumes it is the only master on the bus. Where multiple masters are desired on a bus, for example in a ATE set, I/O pins can be used to handshake between masters, or to reset/disable the other master when the BL233 wants the bus.

  1.  
  2. Table 2: Command Character List
  3. Char

    Command

     

    Chars to Follow

       
    0-9

    A-F

    Hex   1-8 lower case a-f are NOT hex  
    : PauseUntilEOL     Pause execution until EOL char received. (except in EE, see below) 5.8
    ;

    :

    ReturnToRS232IfChars

    ForceReturnToRS232

        Execution returns to RS232 buffer if there are chars in buffer, otherwise continues in EE

    Execution unconditionally returns to RS232 buffer if in EE

     
    < Return   0 Execution returns from a macro, either to calling macro or RS232 buffer  
    = unused        
    > Jump to EE   2 Execution jumps to macro in EE  
    ? Query Status   0 returns status register 6.2
    @ unused        
    G Set Bus Number N 1-F Sets the I2C Bus to use. Will execute STOP (P) before changing bus. 5.6
    H Hi-speed start     Future Use for HS mode  
    I Check Interrupt I   Checks Int pin, and execute Int macro regardless of fInterruptEnable 6.3
    J Write Control Flags & Timing       6.1
    K          
    L Delay NNNN ms Dnnnn 4   5.7
    M Set Message Number Mnn 0,2   7
    N          
    O Output Direct to Pins   1-8 write direct to pins and tri-state registers 8
    P I2C Stop P 0   5.2
    Q Query Direct from Pins Q 0 Reads pins directly 8
    R Read nn bytes Rnn 2 Reads NN bytes from previous address (I2C) or SPI, 1Wire 5.5
    S I2C Start S 0-8   5.1
    T Type Char Tnn… 2-8 Types data back 6.3
    U Dump EEProm U 0 Dumps whole EEProm 11.6
    V Write EEProm Vaadd…   Write eeprom from address aa 11.5
    W Write Wdd…   Writes bytes to previous address (I2C) or SPI 5.5
    X Software Reset 5A   "X5A" forces a power on reset 15
    Y SPI Mode n   Set SPI Mode. N sets bits to send for next write to do short writes. 9
    Z sleep       16
               
    , (comma) ignored        
      (space) ignored        
    0x80

    0xFF

    Chars>=0x80 are used as ASCII     Special mode, not normally enabled  
               
  4. Command Format
  5. The BL233 uses a simple printable Ascii format. Hex characters are used for all data and I2C addresses. Other characters are used as single char commands. Unrecognised chars are generally ignored.

    Chars are generally processed and acted on immediately.

    The basic form follows that shown in the Philips I2C documentation.

    1.  
    2. A simple I2C Transaction
    3. Consider writing 0xD7 to a Philips PCF8574 8 bit Port. The base address is 0x40.

      Send:

      S40D7P

      [I2C Start][Address:0x40][Data:0xD7][I2C Stop]

      The command S sends an I2C Start. P is an I2C Stop, just like the Philips documents.

      To send a string of 80/81/80..… to the port:

      S 40 80 81 80 81 P

      Repeated Start:

      S 40 80 81 S 82 S83 P

    4. Stop
    5. P returns the I2C bus to the idle state. You should leave the bus stopped when it is idle. Interrupts and other automatic actions need the bus to be stopped, so they don't split an indivisible operation
    6. Reading I2C
    7. The adaptor looks at bit 0 (R/W bit) of the address byte. If 1, this is a read.

      To read, set bit 0 of the address eg: read 2 successive bytes from address 0x40

      S410A

      [I2C start][Address:0x40 R/W=Read][Number Bytes to read: 10 (0x0A)]

      The adaptor replies with 0x83 both times:

      8383[eol]

      Repeated Start:

      S407D,S4101,P

      7D[eol]

      [start][write 0x7D][repeated start][read 1 byte][stop] [adaptor returns 1 byte)]

      1.  
      2. Reading an indeterminate number of bytes: Pascal Strings

      Due to the way the I2C bus works, (master controls reads), the master has to know how many bytes to read. If the device is returning an indeterminate number, eg a string, then we have a problem.

      The BL233 has support for reading pascal style strings. If the NumberOfBytes is 0, then it will take the first byte read from the I2C slave, to be the string length.

      eg an I2C slave (0x40) has the string "Hi", ie 0x 02 48 49

      S4100

      4849[eol]

    8. 10 Bit Addresses
    9. Carefully study the Philips notes on 10 bit addressing. In short: you write 2 address bytes, so any read is done by a write(2 address bytes), then a read, with only the first address byte.

      The R and W commands are particularly useful with 10 bit addresses to reduce traffic.

    10. R and W: Fast Read/Write Commands
    11. Where you want to read or write to the previous address use R and W. eg instead of

      S4083 S4101 S407D P S407E S4101 P

      Using R and W to read and write the previous addresses is much shorter.

      S4083 R01 W7D W7E R01 P

      10 Bit addresses will be correctly handled.

    12. Selecting the I2C Bus
    13. G selects the I2C Bus. If the bus is not in the stop (P) state, then the adaptor will execute a P before changing the bus.

      Busses 1-4 are separate busses. Busses > 4 use the same pins in different ways. It is important to write your code to allow bus numbers to be easily changed to allow for future BL23X chips.

      S4083 G2 S4084 G1

      [Write 0x83 to PCF8574 on Bus1][Select Bus 2][Send 84 to another 8574 on Bus2][return to bus 1]

      Multiple I2C Busses allows you to have more of one type of chip than sub addressing allows. (eg 24 PCF8574's).

      Bus # SDA SCL SDA In SDAOut SCLIn SCLOut CS Fast  
      1 18 17              
      2 1 2         3    
      3 13 12         11    
      4 3 11              
      5 18 17           #1 Bus 1 Fast
      6 1 2         3 #2 Bus 2 Fast
      7 13 12         11 #3 Bus 3 Fast
      8     1 13 2 12     Full split, Bus2 is inputs, Bus 3 outputs
      9   2 3 1         Bus 2 Half Split
      A   12 11 13         Bus 3 Half Split
      B                  
      C 1     2         1Wire#1
      D 3               1Wire#2
      E 13     12         1Wire#3
      F 11               1Wire#4
                         

      Some bus numbers use some or all of the same pins as another bus.

    14. Delaying
    15. To output a pulse we can use Delay (L). Delay is up to 65535 milliseconds.

      S4001 L0400 W00

      [Set bit0 of PCF8574 HI][Delay 0x400ms ie ~1 sec][Set bit 0 LO]

    16. Pause Command for Timing Critical Sequences
    17. ':' (colon) pauses execution until an EOL char (CR or LF) is received. Chars after the ':' are stored in the buffer, but not processed until an EOL char is received. This ensures that the sequence of operations between ':' and EOL will always take the same time, irrespective of baud rate or undefined computer delays.

      :S4001 L0001 W00 [eol]

      [pulse bit0 high for 1ms]

      Obviously the string between ':' and EOL must fit in the RX buffer.

      (hint: using ":" can make it easier to watch data sequences on a oscilloscope)

    18. I2C Acknowledge
    19. Read the Philips I2C documentation closely.

      At the end of each byte transfer there is an acknowledge.

      1.  
      2. Writing

When writing the slave generates ACK. (pulls the bus LOW)

If the slave does not ack, then either

Most hardware designs and hardware type I2C slaves are deterministic.

For this reason the default is to ignore nack. You can check the result of the last writes by QueryStatus (?). This is an easy way to check the bus for I2C devices at power on. Nack is cleared at each START. Note that "?" can be put between data bytes.

Two fControl flags offer more sophisticated nack handling

fControl
Bit Rst Name Description
3 1 WrIgnoreNack

(default)

makes I2C write routines ignore nack. The interface will continue to write bytes to the bus even after a nack.

Writes halt when nack occurs. Subsequent bytes are ignored. Writes "N" back to host

1 0 AckWrites writes K/N as each byte written to I2C is/not acknowledged by the slave

"K" nack'd OK

"N" failed to nack

Useful for debugging. Clears Nack at each byte

      1.  
      2. Reading

When reading from a slave the nack is generated by the master (BL233) as each byte is received.

The I2C Bus requires that after receiving the last byte a master doesn't nack. This signals end-of-data to the slave.

The BL233 handles this automatically.

However you might wish to read a large number of bytes from a slave (eg >255), or read as a series of shorter blocks, without signalling end-of-data to the slave.

In this case you can set the flag fControlReadBlockAck. In this case all reads will be ack'd, and you must take care of the last read yourself with an N before the final read. Note that you can read multiple blocks by sending a series of byte counts. So you could use "R 02 03 04 N 01"

"N" makes the last read NOT ack, thus signalling the end to the slave.

Note that this all seems a bit complicated, and for most slaves you can probably just end with a stop.

  1.  
  2. Status and Control Registers
  3. fControl

    Bit Default Name Description
    7      
    6 0 EmitWriteResult returns data read as byte written (see SPI)
    5 0 RxWatchdogEnable enables the watchdog on rx chars
    4 0 InterruptEnable enables interrupt response
    3 1 WrIgnoreNack makes I2C write routines ignore nack
    2 0 RdBlockAck nack won't be sent when last byte is read
    1 0 AckWrites writes K/N as each byte written to I2C is/not acknowledged by the slave
    0 0 MessageNumsEnabled enables return of message numbers

    fStatus

    Bit   Default Name Description
    7        
    6     1WirePresence if a presence pulse exists during reset
    5     1WireInterrupt A device signals INT during reset pulse
    4     Int Current state of Interrupt pin (0=active int)
    3 *   TimerTimedOut  
    2 *   FifoOverflow Either RX or TX fifo overflowed
    1 *   ClkStretchTimeout I2C timed out waiting for SCL to go Hi
    0     Nack result of last I2C Nack
    1.  
    2. Setting Control Register and Bus Timing
    3. To set the control register

      J [control register]

      To change the I2C Bus timing. 0 is fastest, 255 is very slow.

      J [control register] [I2C Timing]

      eg Enable Interrupts

      J04

      eg Enable Ints and set I2Ctiming to 15

      J040F

    4. Querying Status Register

? returns the status register. This is most commonly used to

"?" does not interfere with the command currently being executed, so you can put it in the middle of a series of bytes being written, or between reads.

    1. Interrupt Pin

The default interrupt routine just types "i" back.

To enable interrupts set the control register eg.

J18

If you want to wait for interrupts, then a simple macro in eeprom will loop waiting for interrupts.

I;>60

(start is at location 60)[Check Ints][return if the PC sends a char][jump to 10 (start)]

Change the interrupt macro to be

T69:

[type "I"][leave EEProm]

Then to run the "wait for interrupt" macro

>60

Now when INT goes low, a single "i" is typed. (with the the original macro "T69<" it returns, and prints "i" repeatedly while INT is low)

    1.  
    2. Return a Char

T types a char back to the PC. It is very useful for formatting and synchronising data.

S407D T563D R01

V=7D[eol]

[set 8574 to 0x7D][Type "V=" back to PC][reads 8574: 0x7D]

The start-up welcome "Hi I2Cad VXXX" message works this way.

Remember that the I2C adaptor is going to return upper-case hex chars, and a few special upper case chars in certain cases (eg N,K)

Type different chars or lower case chars back, then it is very easy to separate them out of the data stream.

 

  1.  
  2. Message Numbers
  3. Message Numbers provide a way of dealing with latency. The message number is 8 bits

    Without message numbers it can be difficult to pair up commands and returned data, especially when long latencies are involved. eg

    S407D R01 D0100 R01

    7D[eol]7D[eol]

    If we turn on message numbers, and set the message number to 0x05

    S407D M05 R01 D0100 R01 D0100 R01

    057D[eol]067D[eol]077D[eol]

    Now it is easy to pair each query to its reply.

    Message numbers are 8 bits, autoincrement, and wrap around from 0xFF -> 0

    Message numbers are enabled by fControlMessageNumsEnabled, or by the first occurrence of an M.

    M without data will clear the message number.

    S407D M05 R01 M R01 R01

    057D[eol]007D[eol]017D[eol]

    Another way to synchronise, is to use "T" to type specific chars back.

  4. Direct Pin I/O
  5. The BL233 makes a great 8 bit I/O port for a PC!

    You can read and write 8 pins directly. The 'O' output command can be used to write to the output pins, and the data direction registers. The bit number of each pin is given in 2 Table 1: BL233 Pinout Description.

    Expects sequence of O Data, Tristate , Data, Tristate …..

    You can write 1 or more bytes in this sequence

    O 0F 0E 5A

    [write][Data=0x0F][tristate=0x0E ][Data=5F]

    Inputs have tristate register bits = '1'. Outputs have tris=0.

    You have to take great care using direct pin I/O when you are also using serial busses, as the bus functions of the chip expect the registers to be set up a certain way.

    All bus pins have DATA bits=0, TRIS bits=1

      1. Pin Timing

    Writes and reads to the pins are done with bits 0-4 changing first, and bits 3-7 ~1µs later.

  6. SPI
  7. 8 bit bytes are written using SCL and SDA. Data is shifted out MSB first, (as is I2C). The bus must be in STOP before using SPI write. The SPI strobe or CS pin function is done using direct I/O above.

    SPI Mode is entered by the "Y" command. SPI mode is exited by "Y0"

    P Y W 01 02 03

    [I2C Stop][SPI Mode] [write 0x01,0x02,0x03]

    P Y R 03

    [I2C Stop][SPI read 3 bytes]

    P Y 01 02 03

    [I2C Stop][SPI write 0x01,0x02,0x03][CS low]

    1. CS/Strobe Pins
    2. These are driven by simple bit bashing using the direct I/O command "O" above. Don't forget that the direction byte must be set before writing data bytes

      O EF Y W 03 04 O FF

      [Set bit 4 (Bus2 CS) LOW][SPI write 2 bytes][Set bit 4 (Bus2 CS) HI]

      Note that our I2C-2-PC board uses P5 for Bus#2 CS, and P6 for Bus#3 CS.

    3. Short Data
    4. Unlike I2C, SPI can have any data length. You can short transfer by specifying the bit count after Y as a single hex digit. This only shortens the next byte. Subsequent transfers will be 8 bits. Data is in the least significant bits of the byte, and data read will have 0 in the unused bits.

      Y W 5A Y2 W 03 AA Y2 R 02

      [SPI][write byte 0x5A][Set for 2 bits][Write 2 bits 0x3][write fullbyte 0xAA][read 2 bits, then 1 full byte]

      Bit count=0 exits SPI mode.

      Bit count 8-15 is for bidirectional mode below.

      Note you can write directly after the Yn command eg

      Y2 03 AA 55

      [write 2 bits (0x03), then full bytes 0xAA, 0x55]

    5. Bidirectional (simultaeneous) Write/Read
    6. Some SPI and 1Wire operations need to read in the data pin as data is written out. This is supported by the fControl bit fControlEmitWriteResult.

      To enter this mode use "Y" with bit count>=8

      To exit the mode use "Y" with no bit count.

      For each byte written, a byte (2 hex digits) is returned.

      Alternatively you can write fControl directly. Note that changing the bus will clear this bit.

    7. SPI Clock Polarity
    8. BL233 does not change the data and clock at the same time. So it will work with both rising and falling edge clocked devices. There is more timing margin at the rising edge, so this is preferred.
    9. M5451

    The M5451 devices do not use a CS or STB line. They take 36 bits data, the first bit is 1. To reset/synchronise them after power on write 5 bytes of 00.

    To write to them it is fastest and easiest to send 5 bytes of data. The first data bit should be one, and all trailing unused bits must be 0.

    Only one M5451 can be connected to each bus.

    If using 7 segment displays with an M5451, we recommend the BL301 I2C Versatile Display Driver. It handles the 7 segment decoding and bit re-ordering for you, and connects multiple M5451's to a single I2C bus.

  8. 1Wire Bus

The BL233 has support for Dallas 1 Wire bus, using the standard timing.

Eg to read a DS2401 serial number

GC S ? W33 R04

[Select 1 wire bus#1 (bus #C)][Start(reset)][Get status to check presence][ReadRom Command][Read 4 bytes of rom data]

Since Start can be followed immediately by write data, a shorter version is:

GC S 33 R04

[Select 1 wire bus#1 ][Start][ReadRom command][read 4 bytes]

The 1Wire Reset (Start) checks for interrupts, and presence of a chip. Read the fStatus ("?") to check these flags. If you are using an iButton application where it is possible to short the bus, you can directly query the bus pin with the "Q" command, if interrupt and presence are both true.

    1. Pins
    2. 1Wire uses a single open collector I/O pin, and a 1k5 pullup resistor. However we also have a second output pin on some buses. This allows for easy galvanic isolation, or for improved bus driving hardware. For a simple bus, you can just use the SDA pin, and ignore SDA_OUT
    3. Software

You can easily use BL233 with the Dallas "Open Source SDK" for high level 1Wire software. BL233 provides support for byte-read, byte-write, N-bit read/write, "touch" (write & read). With these you can get complete 1 wire functionality.

 

  1.  
  2. EEProm Memory

The 128 Bytes of EEProm contains:

    1.  
    2. Table 3: EEProm Memory Map
    3. Address ~Add

      Register

      Description

      see

      0xF7 08 fSerial RS232 Control Register 6
      0xF8 07 Baud_Div Baud rate divisor 12.3
      0xF9 06 TimerDivL Low byte of timer divisor (TimerDiv) 13.1
      0xFA 05 TimerDivH Hi byte of timer divisor 13.1
      0xFB 04 fControl Control Register  
      0xFE 01 IRQ1Vector Macro address for interrupt 6.3
      0xFF 00 Watchdog Vector Macro address for watchdog 14
      0   Base / POR First macro instruction. Power-On jumps to this location.  
               
               
      0x76   end Generally contains a return char ">"  
    4. Macros

Macros are stored command chars.

    1.  
    2. A Macro for combined 8 switches + 8 Leds board
    3. This board uses (you guessed it) an 8574. The 8574 is a open-drain driver. We can connect switches across the drivers, and read the switches if we momentarily turn the LEDs off (write 1's)

      S40FF R01 W <

      [write 0xFF to turn leds off][read 1 byte][start write][return] we now expect the LED data to follow.

      To use the macro:

      >20 00 P

      [goto macro][new led data][stop]

    4. A simple "program"
    5. This is a simple data-logging application. It reads the 4 A-D channels of a PCF8591, and 8 switches with an 8574, 4 times a second, and streams the data to a PC, that captures it with a terminal program.

      start location is 0x10

      S9104 S4101 P D00F9 ; >10

      [read 4 a-d][read 8574][delay 249ms][return if the PC sends a char][jump to start]

    6. Writing the EEProm
    7. To prevent inadvertent writes to the EEProm, the start address is sent twice. First normally, then inverted. If they don't match, the whole operation is aborted.

      The format is V[address][not addr][byte1][byte2]…..

      Address 0 is the Base / POR location. So to write F1,01,11 to the POR location:

      V00FF F1 01 11

      Each byte written takes 10ms. You need to either send data slowly enough, or in small packets eg 8 locations to avoid overflowing the buffer.

      The EEProm write command is intended for configuration, rather than routine use. You must check that vital data is correct. In particular if the serial parameters are wrong, you will be unable to regain control after the next reset.

      (hint: to find the hex for the char string you want to put in EEProm, set Realterm's display mode to hex+ascii, half-duplex. Now type the string, and you will see the hex.)

      1.  
      2. Write Protecting the EEProm

      If fSerialEEWriteProtect is set, further writes to EEProm are blocked unless in Special Pins Mode

    8. Dumping the EEProm

U will dump all 128 bytes of EEProm in the order shown in Table 3: EEProm Memory Map. ie the first byte is fSerial, not Base/POR

  1.  
  2. Serial Comms
    1.  
    2. EOL and Separator Chars
    3. Both the EOL char and the separator char can be set in EEProm. They can be changed to get a different data format that is easier to use.

      EOL (LF 0x0A by default) is sent back to separate commands.

      The separator char is not used by default but may be set to any value that suits the particular program interpreting the data. Eg comma, space, or tab. This will add 50% comms overhead of course.

      e.g. Change separator to TAB, and EOL to CR, to make Excel readable files

    4. Data Format

Data format cannot be changed.

    1.  
    2. Baud Rate
    3. The baud rate is set by writing the ee_BaudDiv and ee_fSerial locations in EEProm. The changes will become active when the part is next reset.

      BaudDiv Values for other Baud Rates (14.7456MHz)

      BaudDiv: 0x 03 07 0F 17 2F 5F BF
      Baud Hi 230k 115K 57.6k 38.4k 19.2k 9600 4800
      Baud Lo       9600 4800 2400 1200

      Baud rates can be calculated at other crystal frequencies from:

      BaudRate HI= Fxtal/(16(N+1))

      BaudRate Lo= Fxtal/(64(N+1))

      For example to change the baud rate to 9600,

      V F807 5F

      [write eeprom][address, ~address][BaudDiv=0x5F]

      1.  
      2. Special Pins Mode

      As you can cock the baud rate up, and be left with an unusable chip, we have provided a special mode where the baud rate and fSerial are in their factory state. To enter SPM, force Pins 1,2,17,18, and 6 to 0V, during and 500ms after reset / power on. Now you can change the EEProm values.

    4. Max Baud Rate and Speed
    5. The BL233 can have baud rates as high as 921kbd. However it cannot process commands at this rate. Different commands take differing amounts of time to execute, and so you should experiment to find the optimal rate for your application. It is likely to have an appropriate throughput for 115kbd.

      Where speed is an issue, make use of macros stored in EE to reduce the serial traffic.

      1.  
      2. PC Serial Port Latency
      3. While Windows PC's, USB devices, and anything running over the internet, have high data throughput (bytes per second), they have long latencies or transit times.

        On a Windows PC that can send 10,000 bytes/sec, it may take as long as 300ms for a single char to loop back.

      4. RS232 Drivers

      At high baud rates (20k +) you need to pay attention to the RS232 Drivers. Driver IC's vary in their ability to drive longer cables at high speed. Variants, eg xxxE parts can have different speeds. Different manufacturers versions of the same part have different speeds. Also beware that at the PC end, some serial ports eg older laptops, may use low power drivers that are rated to 20k.

    6. Serial Buffer Size

It is best to keep command strings within the buffer. When reading a port, avoid reading more chars than will fit in the buffer.

    1.  
    2. Handshaking
    3. RTS/CTS hardware handshaking is supported. It is controlled by bit fSerial_UseRTS. XON/XOFF handshaking is not supported.
    4. Table 4: Serial Initalisation Registers in EEProm
    5.   bit 7 bit 6 bit5 bit4 bit 3 bit 2 bit 1 bit 0  
      fSerial EEWrProt. Enable

      Sleep

            UseXon UseRTS Baud Rate HI  
      BaudDiv Baud Rate Divisor  
                         
    6. USB

The usb has a drawback. Data is passed in 1ms frames. This means that there is a minimum 1ms turnaround for even a single char. Structure your data so that you send as many commands as possible before your program requires a response.

  1.  
  2. Oscillator
  3. The standard oscillator frequency is 14.7456MHz. This permits standard baud rates as high as 921kbd.

    As the BL233 is much faster than many applications will require, you can change the crystal for a lower frequency. This will allow operation at lower voltages, lower supply current, and reduced EMI.

    Both BaudDivisor and TimerDivisor can be set in EEProm.

    The max oscillator frequency is 20MHz. The I2C Bus timing is set for Standard Mode at 14.74MHz

    1.  
    2. Timer

    The timer ticks run at 1ms with a 14.7456MHz crystal. You can change the timer rate using the 16 bit EEProm register TimerDiv.

    Timer Rates @ 14.7456MHz

    Timer Div 0x0E66 0x01CC 0x3840 0x4800 0x9000 0xFFFF
    Timer 1ms 2ms 256Hz 5ms 10ms 17.8ms
    Watchdog 66s 2m 11s 4m 15s 5m 28s 10m 55s 19m 25s
  4. Watchdog
  5. The chip has a watchdog function that is used to monitor correct functioning of the host computer. A typical use might be to force a hardware reset of the host PC, or to force outputs into a safe idle state if the controlling PC crashes.

    The watchdog period is fixed at approx 216 timer ticks, normally ~65secs.

    Each time a character is received from the host, the watchdog is restarted. After 216 ticks without a character received, a watchdog event can be generated.

    If the watchdog vector is not 0, and the RxWatchdogEnable is set, then execution jumps immediately to the watchdog macro. The current character will be processed, then the next char is fetched from the watchdog location.

    The RxWatchdogEnable flag is cleared, and any pending chars in the input fifo that are waiting for an EOL char, are unblocked.

    You need to bear in mind that bus transactions may be left half completed, and so you may need to use P,S,G or other commands before using the I2C bus.

    The default Watchdog macro just types "w"

    1. Uses
  1. Reset
  2. X5A causes the part to do a power on initialise. (5A is required to prevent inadvertent operation)
  3. Sleep Mode
  4. not implemented

    If fSerial.EnableSleep is set, Z will put the part to sleep. (by default sleep is disabled) It will wake on pin change. This could be from an I2C interrupt, or by the PC toggling RTS. If you need the PC to wake up the via RXD, connect RXD to SDA4 through a resistor.

    You need to allow 10ms for wakeup from sleep.

    If you are waking it with the RXD line you need to be aware of the potential for waking up part way through the char used to wake it. For this reason 0xFF is recommended as the wakeup char.

    Due to the perils of putting the part to sleep this function is not enabled. Contact the factory if your application needs this function.

  5. I2C Bus Connectors and Pinouts
  6. We use this pinout, and recommend that you do also. More details, and connector part#'s, suppliers etc see: http://www.i2cchip.com/i2c_connector.html
    Pin# 6 Way 4 Way  
    1 SDA SDA  
    2 +5 +5  
    3 Gnd Gnd  
    4 SCL SCL  
    5 INT   Interrupt input (active low). Can be used as CS when being used for an SPI bus.
    6 VAux   Aux supply (eg 12V), or other uses.
  7. Example Applications
    1.  
    2. I2C-2-PC: Dual Interface USB & RS232 to I2C Adaptor
    3. This 45x80 mm module can be used standalone in its enclosure, or as an OEM module in your equipment to provide a complete USB and RS232 interface with 3 I2C ports, and 1 buffered high current I2C.

      Galvanic isolation can be installed where the I2C busses need to be isolated from the computer.

      There is an internal 5V power supply to run the interface and target hardware, but for USB bus power can be used. Building an I2C based instrument needs nothing more than your I2C chip, everything else is included.

      An optional Fibre Optic interface is available where very high voltage or totally secure isolation is required.

      An RS422 interface is available for long distance or high noise immunity.

      Ferrite beads are fitted to all data lines for EMC protection.

    4. Simple I2C to RS232 Adaptor
    5. Figure 2

    6. Simple Data logger with no PC Software
    7. Use a Philips PCF8591 4 channel 8 bit A-D chip.

      Store this macro in the EEProm at location 0.

      S90 04 R04 T0A L0200 >00

      [Start][address 0x90 (8591)][Control register=0x04][Read 4 channels of A-D] [Type LF (linefeed)][delay 512 ms][goto start]

      The macro will run automatically at power on, sending 4 channels of A-D data in hex, followed by LF.

      Capture the data to file with Realterm.

      Plot it with Excel, Matlab etc.

      You don't need to send anything from the PC, or write any software. Almost any A-D convertor could be used.

    8. Isolating an I2C Bus
    9. The I2C Bus can be isolated in two ways.

      The easiest is to isolate the serial data stream, and the I2C-2-PC adaptor can be fitted with an isolator to do this.

      However sometimes you want to isolate one bus from others. An example is a current sensor in the positive rail of a power supply.

      In this case you can use the Split Bus feature. This eliminates the need for an expensive part like the 82B96

    10. RS232 to LCD Module adaptor
    11. A single PCF8574 can drive a standard LCD module. This circuit is available built up.

      See the BL301 Versatile Display driver for an easier way to do this.

    12. Huge RS232 Parallel Port
    13. To get are large number of cheap and easy output pins with good drive capability, use the SPI output, and 74HC4094 shift registers. Eg a 32 bit output with 4x 4094's. SDA4 is used as STB for the 4094's

      G3 Y W01020408 OFFFD OFFFC

      [select bus3][SPI mode][send 4 bytes to 4094's][pulse STB pin to latch data] nb O not zero

    14. Hardware Watchdog for Network or Server
    15. Servers and Routers commonly lock up, and need to be reset or de-powered to restore service to whole areas of offices and factorys. A BL233 makes an easy watchdog to restore service.
      1. Circuit
      2. Connect a relay energised by the P4 pin going low. Put the normally-closed contact in series with the mains lead of the server or router. ie When the relay is energised, the server is turned OFF.
      3. Operation
      4. To watchdog a server, run a program on the server to send a char to the I2C-2-PC every few seconds. After 65 secs without a signal, it will reset the machine. Changing the TimerDiv adjusts the period up to 20 minutes.

        To watchdog a router, use a program to check the router connection (eg ping across the router), and send a char to the watchdog when it is OK. Not that both the router, and the PC should be on the watchdog.

        Realterm can be sued to send chars to the watchdog from a batchfile.

      5. Code

    Put this string in the Watchdog macro of the BL232.

    O EF EF L1000 OFF EF J82;

    [turn relay ON][wait 4 secs][turn relay off][enable watchdog][return]

    At 0, (power-on macro) enable the RX watchdog.

    J82

    [enable RX watchdog]

  8. Migration from BL232 A, B

BL232-A is very similar for I2C use. BL232-B is a subset of BL233 for cost sensitive high volume applications, and works the same

  1. Ordering Information
  2. We recommend buying one built up I2C-2-PC adaptor to save time and hassles.

    DIP parts are available in low volume. SOIC and SSOP20 parts are only available for volume orders at this time.

    DIP18: BEL233-P

    SSOP20: BEL233-M

    EEProm settings can be customised at the factory.

    BL232 is available for high volume applications.

  3. Co-operation

We offer all customers a link page on our web site, where others can find out about your products. We encourage you to use this.