Have to put on my thinking cap, memory sucks.
1) You want your camera on AV mode. Using a fixed aperture (e.g. F/4) will maintain the depth of field across all images.
2) In CHDK Main Menu, select Extra Photo Operations.
3) Scroll down in Extra Photo Operations to Bracketing in Continuous Mode and select it.
4) Now, set the TV Bracketing Value to whatever value you would like. If taking 3 photos, use 1 or 2. If taking 5 photos, you can use 1/3 or 1. You can get the idea from here. The more photos being taken, the smaller the TV value.
5) Exit the CHDK menus and go to the Self Timer function. On the SX40HS, it is at the bottom of the scroll wheel on the back of the camera. Press down to enter this function.
6) Select Custom Timer and press the Menu button.
7) The first value is the number of seconds to wait until the first photo is taken after the shutter has been pressed. Five seconds is good as it gives the camera time to stabilize itself after you release the shutter button.
8) The second value is the number of pictures you want to take (e.g. 3, 5, 7, up to 10).
9) Once you have made your selections, press the Set button.
10) Now you are ready to start taking the HDR images. You will have to go through the set-up procedures every time the camera is turned off then back on.
11) It is best to use a tripod for taking the pictures, so mount your camera on the tripod.
12) When you have the picture framed, half press the shutter to get your focus and exposure set up.
13) WIth the shutter half pressed, complete the process by pressing the shutter button fully and let go.
14) The camera will do a countdown for the number of seconds you specified. Once that takes place, the camera will take the number of pictures you specified.
Hope this helps...
Al