Stopwatch function implemented on WP34s



Just for fun, I've implemented a Stopwatch function like the one on the HP-55 and the HP-41C TimeModule.

Of course, it would need a quartz to be precise but I'll see later if I can implement a calibration function.

It is a simple addon to the last firmware version and if someone is interested, I can give the calc.bin and/or the source code.

How it works:

- there is now a TIMER function in the P.FCNS menu, under TIME
- Pressing F then H then EXIT quickly enters the TIMER mode too
- once in TIMER mode, R/S starts & stops the stopwatch
- EEX toggles the 10th secs display
- ENTER stores the current value in memory. 0 to start and the increments
- arrows increment/decrement the memory used
- one can also enter the memory number directly
- the memory used is displayed in the exponent zone and -> toggles it

I plan on implementing a delta mode later, like the TimeModule one but maybe simpler.

Here is what it looks like:



Congrats, new master of convoluted C code! It took me a while before I was able to implement anything in WP 34S.

We'd like to see your sources and would also like to know the memory footprint of your additions. Maybe we can add you to the list of developers on SF. :-)


No luck sending you an email so I did it through silicium.


And received your email. Cannot respond still.


Very nice, the TIMER function is very convenient indeed! Just a question: Given the current (pun intended) worries about CR 2032 batteries being not the best ones to cope with extended activity on these calculators, how feasible is to have the timer running for significant periods of time? Are you deliberately choosing a super-slow CPU clock mode to run the timer?



This is a first implementation and I've not measured battery drain yet. I plan to do so.
Right now, running the TIMER should be the same as running a program but I guess I can try to slow down the CPU clock.

Edited: 28 Oct 2011, 10:55 a.m.


Pascal, you can wire the timer to the heartbeat interrupt. This will run at 2MHz and idle again after return. Just look into keys.c and search for K_HEARTBEAT. You will need a global variable which selects timer mode and disables all other functionality.


This is exactly what I've done. In the main loop, there is a global variable containing a function pointer. If it is not null, it is called on every key pressed including HEARTBEAT instead of the normal processing.

The TIMER function simply sets this variable and exiting it resets its to NULL. This mechanism could be used for any other interactive function which needs full control of the keyboard if we had more space :-(


Well done! :-)


BTW, I ran it for 2 hours straight on brand new batteries and the voltage went from 3.0V to 2.9V.
The WP34s slows down at 2.5V and shutdowns at 2.2V.
So timer's power consumption is not that bad.


I'd like to see your code as well (or diffs).

Too bad the hp20b/30b doesn't have a tone generator, I'd like to have a count down timer.

I wonder what the simplest circuit is to use one of the GPIO pins?


Code is in SVN.


We can not take some factors of conversion?
I believe it is very easy to save some factor in a memory (STO) of him to leave the system fixed.
We could gain a few bytes for further improvements.


Initialized constants are 272 bytes whilst executable code is 122 Kb according to the linker.
So this not where room can be found I guess.


But these 272 bytes could not be used for something more important?
I think that any user can use some memories (STO and RCL) to save your constants.

Edited: 28 Oct 2011, 3:36 p.m.


But then you need to know them. We have a few areas where we might save code such as the integer code which deserves a rewrite in ARM assembly.


Using general purpose registers for constants would cost more *and* have the disadvantage of not knowing the names. We won't do that.



I suspect the conversion constants aren't in the initialised data segment. They definitely take more than 272 bytes.

They are still incredibly compact as commands go. I'd guess eight to ten conversions or constants occupy the same space as the most trivial of commands (think the single bit setting mode commands) and this is including the catalogue overheads.

- Pauli


I suspect the conversion constants aren't in the initialised data segment.

There is no such thing as an initialized data segment, just ROM data. All data in RAM is just zero. I got rid of the 'copy ROM to RAM' sequence all together.

Possibly Related Threads…
Thread Author Replies Views Last Post
  HP50g: Writing a function that returns a function Chris de Castro 2 2,117 12-10-2013, 06:49 PM
Last Post: Han
  [wp34s] Minor Issue with Stopwatch on real hardware RalfGeiger 3 2,125 04-16-2013, 04:12 PM
Last Post: Eric Smith
  [43s] : How the solver will be implemented Miguel Toro 3 1,617 03-14-2013, 06:09 PM
Last Post: Walter B
  [WP34s] RSD function Dieter 11 3,280 01-29-2013, 08:58 AM
Last Post: Walter B
  [WP34s] Parallel function Dieter 25 5,955 11-05-2012, 04:04 PM
Last Post: Marcus von Cube, Germany
  [WP34S] WP34S firmware on the AT91SAM7L-STK dev kit? jerome ibanes 1 1,215 10-04-2012, 04:59 PM
Last Post: Paul Dale
  wp34s INC s function Jeff O. 18 4,534 10-03-2012, 02:20 AM
Last Post: Paul Dale
  WP34S Fibonacci function wildpig 3 1,331 09-02-2012, 02:25 AM
Last Post: Walter B
  WP34s Stopwatch & statistics pascal_meheut 4 1,710 06-14-2012, 09:04 PM
Last Post: Matthew Krotzer
  WP34s Stopwatch & statistics, message for Matthew Krotzer pascal_meheut 2 1,388 05-23-2012, 03:30 PM
Last Post: pascal_meheut

Forum Jump: