BV112

Introduction

This is an I2C to UART bridge, designed to give an extra UART to a microcontroller when only I2C is available. This is an I2C device and thus is configured and controlled by that interface.

Very easy to use: write to I2C and it comes out of the TX pin, read from I2C and it reads from the UART buffer.

Type B has some extra features

Library

There is just one library available written for the ESP8266 MicroPython.

Data sheet in pdf format.

Features

  • Configurable I2C address

  • Defaults to 115200 Baud, configurable

  • INT pin indicates when there is characters in the UART buffer

  • 80 byte UART input buffer (type A 40 byte)

  • Operates on 3.3V or 5V

  • 1 channel DAC 64 steps

  • 4 channel 10 bit ADC with precision voltage reference

Pinout

Type A

Type B

  • VDD Power voltage, this can be either 3.3V or 5V see note

  • RX Serial input

  • TX Serial output

  • F This must be tied high or left open. To reset the device EEPROM to the factory settings, then remove power, set this pin to VSS, apply power and then remove power.

  • SDA I2C data

  • SCL I2C clock

  • INT This pin will go high when there is one or more bytes in the UAART buffer otherwise it will be low.

  • DAC Digital to analogue output

  • ADCn Analogue to digital input

Note:

Any pin must not exceed the voltage on VDD so if a 3.3V power supply is used then the signal pins must also be 0 – 3.3V

DAC

This is an output with a voltage swing controlled by a command from about 0.3V to VDD. It must be switched on (with a command) prior to use. The resolution is 32, 0 being 0.3V and 31 being VDD.

When switching off it will power down the internal peripheral but may not alter the voltage on the output pin.

ADC

The ADC has a resolution of 10 bits (0 to 1023) and is referenced from a precision voltage reference. The reference can be set to VDD, 1.024V, 2.048V, 4.096V To use the last voltage VDD must be 5V.

The ADC takes about 100us which matches the interface and so is not suitable for very high speed applications.

Status Flag

 

 

 

VREF

VREF

ADCON

DACON

BF[1]

[1] bit cleared when read

BF Indicates if the buffer has become full at some point and it is likely that input serial bytes will have been lost.

DACON Indicates if DAC is switched on

ADCON Indicates if ADC is switched on

VREF 0 to 4 indicates Vref value

Type A device will only show BF

EEPROM Locations

Adr

Default

Notes

0

0x55

System use

1

0x48

I2C address

2

0

Baud rate bits 31:24

3

1

Baud rate bits 23:16

4

0xc2

Baud rate bits 15:8

6

0

Baud rate bits 7:0

7

1

Command trigger

14

0x48

I2C address copy

240

0x48

I2C address copy

 

I2C Commands and Operation

By default anything written to the I2C address will be echoed on the TX pin. So for example i2c.write('hello') will appear on the TX pin. I2c.write will use the write address of the device (0x48).

Reading from the i2c will retrieve the contents of the UART buffer (if there is anything in there), so for example, using the read address 0x49, i2c.read(n) where n is the number of bytes to read will get the contents of the UART buffer. If there are no bytes in the buffer 0 is returned.

In short then, writing to i2c is the same as writing to the UART and reading from i2c is the same as reading the UART buffer.

Commands

In order to get information such as how many bytes there are in the UART buffer, or to clear the buffer a command system is in place. A single byte value is the command trigger that is followed by the command itself, the trigger is configurable in EEPROM and cannot be a normal data value.

Both devices A and B

Applies to B device only

The default trigger that must be sent before a command is 1

Command

Range

Notes

1

N/a

Clear the UART Buffer

Example

i2c.write(trigger,1)

2

N/a

Reset

Resets the device as at first switch on. Depending on the I2C master this will likely cause a time out as there will be no reply from the device.

Example

i2c.write(trigger,2)

4

N/a

Turn on DAC

Turns the digital to analogue converter on

Example

i2c.write(trigger,4)

5

N/a

Turn off DAC

Turns the digital to analogue converter off

Example

i2c.write(trigger,5)

6

N/a

Turn on ADC

Example

i2c.write(trigger,6)

7

N/a

Turn off ADC

Example

i2c.write(trigger,7)

11

N/a

Gets number of bytes in UART buffer

Example

i2c.write(trigger,11)

i2c.read(1)

12

V = 0 to 31

Sets DAC

Sets the voltage on the DAC pin, range is from about 0.3V to VDD with a resolution from 0 to 31.

Example

i2c.write(trigger,12,v)

13

Ch 1 to 4

 

Get ADC Value

Returns ADC value for a particular channel. Two bytes are returned forming a 16 bit value, high byte first.

Example

i2c.write(trigger,13,n) // n is 1 to 4

i2c.read(2)

14

0 to 4

Set Vref for ADC

By default the voltage reference is set to VDD. Applies to all channels, this can be changed using this command where n is:

0 = VDD

1 = 1.024V

2 = 2.048V

3 = 4.096V (Vdd must be 5V to use this)

Example

i2c.write(trigger,14,n)

15

N/a

Get Status

Gets status byte see text.

Example

i2c.write(trigger,15)

i2c.read(1)

144

Adr 0-255

Read EEPROM

This will read a single value from an address in EEPROM

Example

i2c.write(trigger,144,adr)

i2c.read(1)

Send the trigger, command and then the address to be read.

145

Adr 0-255

data 0-255

Write EEPROM

Writes a single byte to the given address

Example

i2c.write(trigger,145,adr,data)

160

 

Gets firmware version as 2 bytes

Example

i2c.write(trigger,160)

i2c.read(2)

161

 

Gets device ID as 2 bytes

The first byte is the high byte of a 16 bit number and the second byte is the low byte

Example

i2c.write(trigger,161)

i2c.read(2)


 

Baud rate

This is held in EEPROM as 4 bytes as it is a 32 bit number the following table has some pre-calculated values

Rate

Adr 2

Adr 3

Adr 4

Adr 5

1200

0

0

4

0xb0

2400

0

0

9

0x60

4800

0

0

0x12

0xc0

9600

0

0

0x25

0x80

14400

0

0

0x38

0x40

28800

0

0

0x70

0x80

57600

0

0

0xe1

0

115200

0

1

0xc2

0