pmeerw's blog

May 2013

Fri, 31 May 2013

I2C device (TAOS TSL45315 ALS) test with Bus Pirate

Bus Pirate is a USB device that connects to a variety of digital electronic components (e.g. EEPROMs, sensors) via protocols such as I2C, SPI, UART, 1-wire. Towards the host-side it offers a serial terminal with a single text interface, so no software to install.

So I want to hook up a TAOS TSL45315 ambient light sensor (ALS) via I2c. The most difficult part is to find the right cables of the Bus Pirate for the SDA, CLK, GND and 3v3 signals.

Then fire up a terminal (minicom -D /dev/ttyUSBx) and you'll see the Bus Pirate prompt: HiZ>. Help is available with ?. Typing m 4 3 changes to I2C mode, W turns on the power supply output, P enables pullups.

Entering (1) runs a macro which scans the I2C bus for devices; here a chip with 7-bit address 0x29 shows up (yeah, this is our TSL45315 -- check the datasheet!):

Searching I2C address space. Found devices at:
0x52(0x29 W) 0x53(0x29 R) 

To turn on the sensor and make a measurement:

I2C>[0x52 0x80 0x03]
WRITE: 0x52 ACK 
WRITE: 0x80 ACK 
WRITE: 0x03 ACK 

I2C>[0x52 0x84 [ 0x53 rr ]
WRITE: 0x52 ACK 
WRITE: 0x84 ACK 
WRITE: 0x53 ACK 
READ: 0xC6 
READ:  ACK 0x00 
The first command ([0x52 0x80 0x03]) addresses the chip for writing (0x52) and sets the value 0x03 to register 0x00 (the MSB has to be set). The second command ([0x52 0x84 [ 0x53 rr ]) selects the data low register (0x04, MSB set, hence 0x84) and then instructs the chip to read two bytes. The results is 0xc6, 0x00 which gives the ambient light in lux: (0x00 << 8) | 0xc6.

posted at: 11:44 | path: /projects | permanent link

Mon, 27 May 2013

FTDI USB/serial converter EEPROM programming

FTDI makes popular USB/serial converter chips; they have a unique, readable number (think copy control) and some EEPROM configuration.

Luckily, there is a nice 3rd-party Linux program, ft232r_prog to control them:

$ ./ft232r_prog --dump
ft232r_prog: version 1.24, by Mark Lord.
       eeprom_size = 128
       vendor_id = 0x0403
       product_id = 0x6001
       manufacturer = FTDI
       product = FT232R USB UART
       serialnum = XXXXXXX
       txd_inverted = 1
       rxd_inverted = 1
       rts_inverted = 0
       cts_inverted = 0
       dtr_inverted = 0
       dsr_inverted = 0
       dcd_inverted = 0
       ri_inverted = 0
       cbus[0] = TxLED
       cbus[1] = RxLED
       cbus[2] = TxDEN
       cbus[3] = PwrEn
       cbus[4] = Sleep

I really like the feature to invert RX/TX logic levels. Came in handy to hook up an old beagleboard.

posted at: 21:03 | path: /projects | permanent link

Made with PyBlosxom