This article was originally published as pdf file by OldGit in the CHDK forum [1].


At the time of writing (mid 2009) the udumper code was not working on the SX200 IS and my integrated sound card introduced an unacceptable level of noise into the signal, so I failed with the “blinker sound card” method. I was also frustrated by the many variables inherent in the sound card method. So I decided to try the RS232 route to blink the firmware.

This was a “last resort” for me, and as you will see, it is NOT the easiest route, I am documenting it here in case anyone else finds it useful in the future. This design is a mixture of data from Manufacturers Data Sheets and the small amount of Electronic experience I have.

The usual disclaimers apply, but anyone is welcome to use this material in any way they wish.

Plus Points (for me)

This “RS232” method has the advantage of “cleaning up” the received analogue signal and converting it to voltage levels that can then drive the RS232 port on the computer in a reliable manner. Using Realterm to record the incoming data to a file results in a direct firmware dump and, unlike the sound card method, it requires no further processing before disassembly. Note however, that the file did need the beginning and end trimmed back to remove the “control data” from the start of the file and the “blank” area at the end of the file.

Down Side

The method used involves building a small circuit and modifying the blinker code.

What You Need[]

If you are not happy building circuits maybe a friend could build it for you.

You will need as a minimum a Solder Iron and a Multi Meter.

An Oscilloscope (Scope) is very useful to ensure correct timing but you can calculate / judge this if you don’t have one.

You also need the components, a small prototype board, the ability to alter the blinker code, and patience !.

What You Don't Need[]

You do NOT need to understand this circuit completely, a basic understanding should be enough.

Basic Idea[]

The basic idea is to use a comparator (ref U1) to switch “on” and “off” a TTL level (+5v) pulse when the input signal from the phototransistor (ref Q1) rises above the reference voltage set for the comparator.

The comparator output pulse is then converted to RS232 levels ( + / - 15v) by the RS232 Interface (ref U2).

This is the circuit and values I used, many values are not critical and can be changed (see circuit notes that follow).

  • Note that Integrated Circuit (IC) pins shown as N/C are Not Connected.

232 Blinker Circuit1

232 Blinker Circuit

Circuit Description[]

  • Working from the left, I powered this circuit from a spare disc drive connection in the PC. This gave me 5v that is then feed into C1. C1 ensures that the incoming supply voltage is “smoothed” of transient spikes.
  • The sensor part of the circuit is the same as that used for the sound card method, A phototransistor or photodiode (Q1) allows the signal voltage to rise when light is sensed. Variable resistor (RV1) is adjusted to give the maximum voltage rise at U1 pin 2, when Q1 is energised by the camera AF diode (light on).
  • The comparator (U1) switches its output (pin 7) high (+5v) when the sense voltage goes higher than the reference voltage at pin 3. RV2 is used to adjust the reference voltage until the comparator switches correctly. Pins 5 and 6 of U1 are shorted together to reduce noise. R1 is a “pull-up” to “help” the comparator output to reach +5v thus giving a clean, square waveform.
  • Note that this design does not have a hysterysis resistor, this can be added between pins 3 and 7 of U1 if required (hysterysis is the range of signal input voltages at which the comparator output is in transition (not fully on or fully off), I didn’t need one but it could be added by soldering one onto the underside of the board directly onto the IC pins (I suggest values between 22K and 100K).
  • The RS232 interface IC (U2) accepts the TTL (Transistor to Transistor Logic) inputs (+5v for a logic 1, 0v for a logic 0) and converts it to RS232 logic levels ( -15v for logic 1 and +15v for logic 0). This signal (Rx Out) is then sent to the PC RS232 port (pin 2 on a 9 way D Type connector, pin 5 of the connector is the signal ground that is linked to our 0v). Note that the input signal logic is reversed on output, as well as having the voltage range increased.
  • Capacitors C4, C5, C6 and C7 are used by the “Charge Pump” within U2 to generate the required + and – 15 volts.
  • C2 and C3 are decoupling capacitors for the ICs (integrated circuits).


Q1                  SFH 300 (or other phototransistor or photodiode) 
U1                  LM311 (or similar comparator) 
U2                  MAX202CPE (or other TTL / 232 Interface from same family) 
R1                  1K Ohms Resistor (or similar value) 
RV1                 500 Ohms Variable Resistor (or value can calculated and replaced with fixed resistor) 
RV2                 20K Ohms Variable Resistor (or 2 fixed resistors to give required ref voltage) 
C1                  10 uf  Electrolytic Capacitor (or similar value) 
C2,C3,C4,C5,C6,C7   0.1 uf   Capacitor (see Construction Notes)

Construction Notes[]

  • Build the circuit on strip board, matrix board or similar (I used a strip board).
  • Use IC sockets (much better for soldering and testing)
  • U2 is a Static Sensitive device, use the proper precautions !!!! (if you are not familiar with static sensitive precautions look it up on the internet, but don’t get scared)
  • C4, C5, C6 and C7 can be any type of capacitor and may be between 0.1 and 0.47 uf but MUST all be the same type and value. If you use electrolytic types observe the polarity shown on circuit (and yes the polarity shown is correct, C4 and C7 are supposed to be that way round).
  • The only critical layout area is the comparator input lines (U1 pins 2 and 3).
  • Keep these lines as short as possible and surround them with 0 volts.

232 Blinker BoardLayout1

Board Layout

Hardware Setup[]

  • If you are using a meter for testing and timing, increase the “bit length” time by amending the software with a multiplier value of 9600 to give 1 second pulses, this will allow time to take the readings.
  • With both U1 and U2 removed and no power on the board, check all lines with a meter or continuity tester, especially the power and ground lines.
  • Any problems with shorted tracks could damage the PC power supply or worse.
  • Before inserting the Integrated circuits, power the board up and test the phototransistor using the camera LED.

  1. Adjust RV1 to give the largest voltage difference (measured at U1 pin 2) between light on and off. (This will also affect the phototransistor sensitivity so keep ambient light levels constant)
  2. Plug in U1.
  3. Adjust RV2 until the output of U1 (pin 7) is seen to switch on and off in a consistent manner.
  4. If you have a scope, check that the output is a square wave and without oscillation at the switch over point.
  5. Power down the board and unplug the RS232 cable from the computer if you've attached it.
  6. Take Static Sensitive Precautions. (Ground yourself, the board etc. Use a wrist strap etc.)
  7. Plug in U2
  8. Power up the board and check that + and – 10 to 15 volts can be seen between pin 2 and 5 of the RS232 connector.


  • If you have access to a Scope, time the RS232 signal and adjust your data bit time length to the required time by adjusting the delay “DELAY232”.
  • If you do not have a scope you will need to make this adjustment by trial and error.
  • Use a multiplier of 96000 and adjust delay “DELAY232” until you get 10 seconds on and off, then remove the multiplier from the code. (this gives 9600 bits per seconf)
  • Adjust the delays “DELAY232” and “DELAYGAP” as required to achieve consistent data transfer into Realterm.


For the SX200 I updated the loader main.c by copying the original blinker code into it. I set the memory start address and LED address, I then only needed to modify the send_byte function for delays and do_bit code for start and stop bits. See the code example below.

Note that the speed (controlled by DELAY232 value) is directly related to the processor speed this is why the SX200 with a DIGIC IV has much bigger values than the original blinker code did.


Run your modified code to dump the firmware into Realterm, wait about 1 hour 20 and when you have the firmware, get yourself a beer, you deserve it.

Good Luck.

Example Code[]

void send_byte(long b) 
// 9600 bits/sec 
// 1 sec approximately = 20569199 Delay on sx200 using 2 nop 
// 20569199 divided by 9600 = 2142 delay time 
// delay for 1 bit pulse 
#define DELAY232   2035 
// delay to allow for any timing mismatch 
#define DELAYGAP   100 
#define nop()   asm("nop\n") 
#define on()    *led=0x46 
#define off()   *led=0x44 
#define delay(value) \ 
    for (i=0; i<value; ++i) { \ 
  nop(); \ 
  nop(); \ 
#define do_bit(i) \ 
  if (b&(1<<i)) { \ 
      on(); \ 
            delay(DELAY232); \ 
  } else { \ 
      off(); \ 
            delay(DELAY232); \ 
    volatile long *led = (void*)LED_AF; 
    int i; 
    // START bit 
    // data bits 
    // STOP bit