Flashlight Firmware Repository

A high voltage programmer or fuse doctor / fuse reseter would be needed to fix reset, spi. But new genuine chips will come with it all be enabled and ready to flash.

Did you ever, even once, get a different error (without “target doesn’t answer”) from those 10 chips?

No, always the same error
avrdude: error: programm enable: target doesn’t answer. 1
avrdude: initialization failed, rc=–1 Double check connections and try again, or use -F to override this check.

Sounds like the same exact problem I had from an eBay seller: polida2008. These chips are probably pre-programmed left over inventory with the reset disabled - probably why they are so cheap. Not that they were ever used, as mounted on a board, but they were programmed for a certain application. Richard at MtnE has the package: Atmel's AVR Dragon, that will disable that, and make them programmable once again. Can't be sure that's your problem but sounds that way.

I didn’t even realise that tk-otc was the single mode group version of BLF-A6, having never looked at it. Somehow you’ve managed to squeeze out another 120 bytes!

I’m not too familiar with bzr and Launchpad, so I’ve posted the code here instead.
This version has:
config_star code removed (before I discovered it was not really necessary)
Single mode group with 6 modes
Memory selection by 16 clicks
20s turbo timeout

Hidden modes

  • Strobe
  • Turbo
  • Biking strobe
  • Battery check (10% steps with ADC values measured from my Attiny13A and % to voltage conversion from HKJ’s tests for the efest 10440)
  • SOS mode
  • Egg timer

Thanks. I added that to the blf-a6-final branch, since it appears to be based on that code. The main/trunk branch has done some refactoring to move common code into shared headers, so this mod might not build quite right there. In any case, it’s online here now:

http://bazaar.launchpad.net/~toykeeper/flashlight-firmware/blf-a6-final/files/head:/ToyKeeper/blf-a6/testedandbaked/

Thanks TK!

I have a question, how do you disable the output on pin 6 of attiny13a in blf a6 firmware. The reason i want to disable the pin 6 is i am only using the pin 5 for output on one 7135 and no connection on pin 6 (no FET or 7135). But the problem is i am getting an occasional blinking when going from high mode to moon mode or even after turning on the light where it goes to moon initially. Maybe the reason i am getting the blink is because the pin 6 is not disabled? So how can i disable it in the firmware?

    DDRB |= (1 << PWM_PIN);     // enable main channel
    DDRB |= (1 << ALT_PWM_PIN); // enable second channel

delete the first line

Thanks, i’ll try that.

Edit: I already deleted that line. There is still blinking between the transition from high to moon mode and also whenever i turn on the light. Maybe i have a bad attiny13a or 7135?

I have a question what code would I need to make a 0805 LED blink on pin 3 while the light was off say once every 5 seconds for example?

I can make it turn on with:

DDRB = (1 << PWM_PIN) | (1 << RED_PIN);
PORTB |= (1 << RED_PIN);



P.S. e-switch driver

The pre-flash is more of a hardware issue. It shows up on some drivers but not others. I’m not sure why, but no code changes I could think of had any effect on it.

First you’ll need to change what it means to be “off”. Normally the driver goes to sleep and will only be awakened by an interrupt such as pressing the e-switch.

Instead, you’ll need to give it some sort of shallower sleep, which will increase standby power and reduce battery life while “off”.

One option is to leave the CPU in a busy loop. It’s easy, but far from ideal. Another option is to enable the WDT interrupt during sleep and add code to the WDT handler to count time and blink the LED periodically. I don’t recall the details of sleep mode right now though… I’m a bit too sleepy myself to remember something I only once glanced at in a hundred-page reference manual. There is a table though, explaining different options for sleep mode and which options pay attention to which interrupts.

Sounds interesting. How complicated is this manual? Might be worth a read.
As long as it’s not significant drain I think I will be ok with it.

It’s just the standard attiny13a reference manual / data sheet from Atmel. I think they call it doc8126.pdf or something like that. It has everything you could ever possibly want to know about the tiny13.

Probably over my head but I’ll try give it a read

I am attempting to compile a version of this firmware with the 2 strobe modes removed. It appears though that I am missing a layout file and AVRStudio 5.1 aborts on the first line of the code… Where can I find that layout file? I did not see it on TK’s page last night in her section.

Thanks Matt

Could you paste the error or the whole output that AVRstudio gives you?

I will re-run the compile this evening and post it.

Atmel Studio 5.1 is pretty dated. I'm running 7.0 now, upgraded from 6.2, slightly better optimization even. Actually I never used 5.1 - started with 6.0 way back. Hhmm - not sure, maybe a header file is miss'n?

There is no AVRStudio layout file because I’ve never used AVRStudio. It’s kind of an unnecessary layer and most projects omit those files. I build it with a single short “build.sh” command, then flash it with “flash.sh”. It looks like this:

(~/src/torches/trunk/ToyKeeper/blf-a6/)-]> ../../bin/build.sh blf-a6
avr-gcc -Wall -g -Os -mmcu=attiny13 -c -std=gnu99 -DATTINY=13 -o blf-a6.o -c blf-a6.c
avr-gcc -Wall -g -Os -mmcu=attiny13 -o blf-a6.elf blf-a6.o
avr-objcopy --set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O ihex blf-a6.elf blf-a6.hex
Program:    1000 bytes (97.7% Full)
Data:         13 bytes (20.3% Full)
(~/src/torches/trunk/ToyKeeper/blf-a6/)-]> ../../bin/flash.sh blf-a6.hex