September 15, 2024

Biscotti firmware -- Convoy S2+ flashlight hardware

The Convoy flashlights (and many others) use an 8 pin Atmel ATtiny13 microcontroller. Actually Atmel was purchased by Microchip in 2016, so these are actually Microchip parts. The ATtiny13a has these specs: Digikey sells these in SMT packages for $0.75 each (and of course cheaper in quantity). If you were experimenting, you might instead want to buy some ATtiny85v chips, which have 8K of flash, 512 bytes of ram, and sell for $1.50.

Some care will be required to write (and build) code that fits in only 1K of flash and that uses only 64 bytes of ram.

Take the 20 Mhz rating with a grain of salt. The Biscotti firmware runs the CPU at 4.8 Mhz. There are 3 speed grades. The fastest will run at 20 Mhz on 4.5 to 5.5 Hz. Left to itself, the part will fire up with a 9.6 Mhz RC oscillator and a 1.2 Mhz CPU and IO clock.

You may be asking what the difference is between the ATtiny13 and the ATtiny13A. The part is the same except for the manufacturing process. The "A" part uses less power at the same operating frequency. A quick look at one of my Convoy lights shows that it has the "A" part.

The "A" part will run any code written for the non-A part, but has two extra registers. These are the PRR (Power Reduction Register) and BODCR (Brown-Out Detector Control Register).

Processor Clock

As shipped the internal RC clock will run at 9.6 Mhz. There is a divider which comes set to 8, which makes the CPU run at 1.2 Mhz and also sets the IO clock to 1.2 Mhz. This divider can be changed. It is also possible to make the base clock run at 4.8 rather than 9.6. The IO clock always runs at the same speed as the CPU clock. The lowest speed grade runs at up to 4 Mhz on 1.8 to 5.5 volts.

Note that all grades will run on 5 volts.

Datasheet and pinout

There is a 176 page datasheet. The pinout for the 8 pin package is: There are also 10 and 20 pin packages available.

In the Convoy, pin 6 (PB1) drives all of the 7135. The data sheet says that PB0 and PB1 can source and sink 20 mA with Vcc=5, 10 mA with Vcc=3.3.

The chip pulls 2 mA at 4 Mhz, 6 mA at 8 Mhz.

Connections for programming

You must connect Vcc, GND and 4 other signals: Note that connecting power and ground will generally be pretty easy. You could temporarily solder the four other wires if you don't have a fancy 8 pin SOIC clip gadget.

Connections in a typical Convoy S2+

Development tools (hardware)

I have 3 small boards with a USB connector on one end, and a 10 pin header on the other. This has an ATmega-8A chip on board, a 12 Mhz crystal and three jumpers.

The ATmega-8A is in a 32 pin package. It has 8K of flash and 1K of ram. Most notably, although it does not include a USB controller per se, it can clearly be made to support USB without additional hardware.

I see these dirt cheap ($1.25) on AliExpress, and they are called USBASP/USBISP AVR programers.
What about the jumpers?

These devices are entirely open, as per the page by Thomas Fischl.
Here is the pinout on the 10 pin header: The RST signal has optional connections based on whether the self programming jumper is present.
Pin 4 and 6 are generally not used.
Feedback? Questions? Drop me a line!

Tom's Light Info / tom@mmto.org