CH341A tool

This is a Windows tool adding extra functionality to popular EEPROM/FLASH programmer based on CH341A USB to I2C/SPI/UART converter - using it as a general purpose interface.

CH341A tool
CH341A FLASH/EEPROM programmer

Before using this type of CH341A-based programmer check if your variant is using 5 V for CH341A power supply. There are some variants that don't have this issue or might even be able to switch between 5 V and 3.3 V (more useful / commonly used), but the ones with CH341A powered from 5 V might be still common. Example "voltage fix".

Functions:

Detecting I2C devices

CH341A I2C device detect

Scanning I2C bus for responding devices, like Linux i2cdetect program. Illustration above shows result with RDA5807M FM radio module connected - this chip has two separate addresses giving access to single and to multiple registers and yet another address (0x60) for compability with TEA5767 chip.

I2C write/read

CH341A I2C write + read

Plain GUI for CH341StreamI2C() API. Sending I2C address, sending optional bytes (from hex string), receving optional bytes (as hex string). Accepts hex string with and without "0x" prefix and with or without comma/whitespace separators.

SPI write/read

SPI on CH341A seems very limited. There are some contradicting informations regarding clock speed, here is my capture from using CH341StreamSPI4() function:

CH341A CH341StreamSPI4

What might be confusing is that clock is irregular - high clock pulses are uniform and have 250 ns, but low state can last around 330 ns (lets call this one regular), around 420 ns (between second and third bit of a byte), around 680 ns (between fourth and fifth bit) or even (between two bytes) around 1170 ns. After averaging this results in ~1.4 MHz clock. CH341A would be not viable for driving WS2812B LEDs.

CS polarity is active low, in my tests CS was activated 11...20 us before the data start and was held down for 930...1110 us after the end of data.

GPIO

CH341A GPIO

This module has no practical use - it was used only to test CH341A API.

Reading data from sensors

CH341A BME280

HTU21/SHT21/Si7021 sensors are cheap but from my experience fragile when used outdoors, in particular humidity measurements is prone to returning incorrect data on a rainy days, so it is not only the PCB but also the sensor itself. I have a small collection of sensors eaten by corrosion and CH341 can be used to double check them.
HTU21 sensors
I have ordered BME280 sensor module some time ago with the intention of replacing Si7021, but it was actually the first time I've tested it.

AS5600 magnetic sensor / encoder

AS5600 sensor
CH341A reading AS5600 angle

This is a quite interesting magnetic field sensor. It measures absolute direction of magnetic field in one plane, up to 360 degrees with 12-bit resolution, working as an absolute angle sensor. Apart from the I2C data it is able to output voltage ratiometric to Vdd or PWM signal. It looks like a possible replacement for potentiometers used in game controllers like joycon.

The kit I've bought from China comes with a small cylindrical magnet that could be connected to controller/potentiometer axis. This probably helps new users as proper magnetic field orientation and strength is required. Magnet should be placed relatively close to the sensor chip - consider using some isolator to avoid shorts due to sticking to goldpin headers.

Reading Smart Battery information

One of the main reasons for writing this tool was the need for diagnosing some old laptop batteries. In the past I was also reselling some batteries bought in bulk and being able to make sure if their controller is fine, read their production date and cycle count would be helpful. I was hoping also for battery repair functionality, it is not trivial though - unlock procedures and/or codes are not publicly known except for few older models like BQ8030.

CH341A is not recommended on NLBA forum as a Smart Battery interface due to poor timings. I have not verified this, but I do indeed have some unstable readings. To gain confidence in data reading needs to be repeated few times.

Dell VV0NF battery (based on BQ8050, Sanyo firmware) required +12V power (despite cells being charged) to communicate over SMBus. Pinout: 1 = GND, 4 = T, 6 = DATA, 7 = CLK, 9 = +. This battery also wasn't working with 100 kHz I2C clock speed, requiring 20 kHz. Dell VV0NF connection
DELL VV0NF

IBM/Lenovo P1137 (for Lenovo R500, T500 laptops, based on BQ8030): plus on the left, GND on the right, DATA on pin 3, CLK on pin 4.
Lenovo P1137 connection
Lenovo P1137

DIP-8 socket can be used as a makeshift cable connector plugged into TEXTOOL socket.
CH341A battery connection

Identifying Smart Battery clock/data can be done by try/error using multimeter and knowing that both these pins would be connected to GND through protection diodes. GND and "+" pins are often marked/visible on the battery and most likely placed on the connector edges.

Note on Smart Battery "T"/System Present pin: it probably needs connecting to GND (I've seen it connected directly or through 1kOhm resistor, I've used 75Ohm resistor myself with Dell VV0NF). If it is not connected I2C on the Smart Battery might be not responding or it might be still active, just reporting battery as locked.

SSD1306 OLED display

CH341A SSD1306 control
CH341A SSD1306 control

Controlling popular cheap 0.96" OLED display based on SSD1306.

HD44780 display

CH341A HD44780 writing

Writing text to HD47780 LCD display connected over GPIO in 4-bit mode. For the connection CH341A programmer pins that are available on goldpin headers were choosen: UART RX/TX and four SPI pins.

HD44780 display connected using PCF8574

This type of alphanumeric display can be bought cheaply on aliexpress. While HD44780 requires normally at least 6 pins for control, adding PCF8574 (I2C to GPIO expander) allows to use it directly with I2C and up to 8 displays can be controlled with a single interface.

HD44780 + PCF8574 display

This consists of two boards connected together (sold as a soldered set or separately) - regular LCD display and PCF8574 piggyback.
This particular display requires 5V power supply. I2C/PCF8574 works fine with 3.3V (and 3.3V is fine for I2C even is display is powered from 5V), but only LED backlight be controlled, LCD itself is blank. There are also variants able to operate at 3.3V, with ICL7660 charge pump soldered as U3 and two extra capacitors.

Note: if the display is blank (either all lit or all black) then contrast might need adjusting (the blue potentiometer).

Connections between PCF8574 and display:

PCF8574  Display
D0       RS
D1       RW
D2       ENABLE
D3       LED control
D4       DATA4
D5       DATA5
D6       DATA6
D7       DATA7

HD44780 + PCF8574 display
HD44780 + PCF8574 display HD44780 + PCF8574 display

MAX7219 8x8 LED matrix

This is an 8x8 LED matrix display controlled by a MAX7219 clone over SPI.

MAX7219 8x8 LED display MAX7219 8x8 LED display

LED matrix is marked as M12088A/B and connected to PCB with two precision SIP sockets. There are few color and brigthness variants, with 25 or 30 mA forward current and 100 mA peak forward current in 1/10 duty cycle, 0.1 ms pulse.

MAX7219 8x8 LED display

Original MAX7219 would be more expensive on itself than this module. Chip that I found inside is marked as GC7219C.

MAX7219 8x8 LED display

The GUI part allows to switch state of each LED individually and control display brightness.

MAX7219 8x8 LED display

Note: I've used 5V to power this display board, but 3.3V signal voltage levels.

RDA5807M FM tuner

CH341A RDA5807M control

Controlling RDA5807M FM radio tuner. Tuner module can be powered from CH341A programmer. For audio output either active speakers can be used or 32 Ohm headphones can be directly driven.

Releases, changelog, source code

Note: using CH341A as I2C/SPI/GPIO interface requires "CH341PAR" driver. If you have used CH341A for EEPROM/FLASH programming, you already have it installed. Otherwise you can download it from https://www.wch-ic.com/downloads/CH341PAR_EXE.html or use my local copy: CH341PAR.zip.

Github: https://github.com/tomek-o/CH341A-tool.


 "Cookie monsters": 7850585    Parse time: 0.001 s