Calculators, anyone?

Anything not related to STM32
dannyf
Posts: 446
Joined: Sat Jul 04, 2020 7:46 pm

Calculators, anyone?

Post by dannyf »

i was going through some old things this week (one of them was a couple of beat-up LPC2103 chips, another story for another day), and found an old HP-12C I bought in the early 1990s - I have a few of them actually but this one even had my old business card taped to it :)

Looking it up here: https://en.wikipedia.org/wiki/HP-12C, and I was surprised to learn that the newer ones ran on LPC1114/1115 (CM0 chips) and some earlier ones on CM4. Some digging around seemed to suggest that many of the HP calculators were implemented on really old chips, like 6502.

That got me thinking: has anyone seen the actual code, preferably C, that implements a calculator? porting it to a 8-bit chip (STM8?) or a STM32F030F4 would be interesting.

for fun or for benchmarking.
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Calculators, anyone?

Post by ag123 »

the blue pill or even stm32f401cc black pill make good candidates, a good thing about stm32f4xx is its floating point hardware, but that probably won't help as it is only 32 bits. it is possibly possible to make a graphing calculator out of it.
dannyf
Posts: 446
Joined: Sat Jul 04, 2020 7:46 pm

Re: Calculators, anyone?

Post by dannyf »

you probably need quadrople ("double double") data types to get to that kind of precision. My compiler (MDK) doesn't support it so I am going to see if I can implement it somewhere (I think Intel has a library out there).

would still be fun to know how they did it 50 years ago, likely with assembly language and on 8-bit machines.
dannyf
Posts: 446
Joined: Sat Jul 04, 2020 7:46 pm

Re: Calculators, anyone?

Post by dannyf »

a couple of beat-up LPC2103 chips,
side note: i am porting arduino to that chip, and it has been quite interesting - comparable to my port of arduino to 8-bit PIC16/18.

the compiler I used is an old MDK (uVision3). compiling 3000 lines and 150KB of code on that thing is instanenous, vs. v4 and v5.

i made me realize how much I missed my Turbo Pascal (1.0 and 2.0) and Turbo C (1.0). Modern doesn't always mean better.
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Calculators, anyone?

Post by ag123 »

there are some arbitrary precision math libraries floating around
https://en.wikipedia.org/wiki/List_of_a ... c_software
i'd guess they can be tried out if they aren't too bulky to fit in flash

for the LPC chips i like the lpc1700 series cortex m3
https://www.nxp.com/products/processors ... 3790745385
and lpc4000 series cortex m4
https://www.nxp.com/products/processors ... 3790399405

I've seen some 3d printer boards sporting the lpc1700 series, but 'development boards' seem hard to spot in the wild.
dannyf
Posts: 446
Joined: Sat Jul 04, 2020 7:46 pm

Re: Calculators, anyone?

Post by dannyf »

the 1768/69 are good chips.

there is a 4300 chip with crazy ADC performance. I thought that was a custom-made chip for someone.

re. calculators - some of the code was made to run on CM0 in emulation mode. So we can certainly port them to a CM3 chip.
dannyf
Posts: 446
Joined: Sat Jul 04, 2020 7:46 pm

Re: Calculators, anyone?

Post by dannyf »

re. the 4300 series - you got me thinking about it enough that I ordered a 4337 board.

200Mhz CM4/CM0, gobs of RAM/flash, tons of peripherals...

All for 15usd shipped. oldies but goodies.

Look forward to playing with it.
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Calculators, anyone?

Post by ag123 »

i've been sticking to stm32 as my sources are the online 'flea markets'
one of those 'monster' boards i bought is the stm32h743VI board from WeAct
https://www.aliexpress.com/item/1005001700815862.html
and as it turns out the stm32h7xx are a 'monster' of a chip.
i think they are among the fastest in the stm32 mcus, and the clock tree is very different from the 'conventional' f3xx and f4xx series.
the peripherals don't follow a sysclock divide by n format and actually has a separate 'kernel clock' and is supposedly 'async'
https://www.st.com/resource/en/referenc ... ronics.pdf

the weact board i bought is a nice board, they have a bundle with some accessories including a ov2640 camera
https://www.aliexpress.com/item/1005001700815862.html
their main 'marketed' use case seemed to be OpenCV, OpenMV https://openmv.io/
but literally, there are a lot of (other) peripherals on chip itself.
the board has a a st7735 (0.96") lcd build on board, based on the schematics
https://github.com/WeActStudio/MiniSTM32H7xx
it goes to an spi port (SPI1 i think).
I did not manage to get that LCD to work, tried Adafruit libraries etc.
it probably has to do with my clock setups, i run the peripherals at 80 mhz 'kernel clock' it could be 'too fast'.
i'm still not quite sure how to fix up clocks for the peripherals yet.
"everything else" seemed to work just well
viewtopic.php?f=28&t=1348
i couldn't remember too well for now but i think the whetstone benchmarks are like the order of 830.69 Mflops (SP)
viewtopic.php?p=8886#p8886
dannyf
Posts: 446
Joined: Sat Jul 04, 2020 7:46 pm

Re: Calculators, anyone?

Post by dannyf »

agreed. that's one powerful chip.
dannyf
Posts: 446
Joined: Sat Jul 04, 2020 7:46 pm

Re: Calculators, anyone?

Post by dannyf »

Out of bordom, i benchmarked (highly unscientifc) a few chips for their floating point math performance - in part to see how the good old LPC2103 (ARM7TDMI) fared. the particular piece of code I'm running here is the mandelbrot series.

the measurements are done in terms of "ticks" - the smaller the numbers are, the faster the chips are, and the CM4F has its FPU turned on.

Code: Select all

architecture	float		double
arm7tdmi-s	 16,041,631 	 25,193,937 
cm3		 21,308,501 	 36,765,315 
cm4f		 2,657,315 	 36,034,287 
mips-4k		 21,364,861 	 35,093,402 
cm0		 28,467,000 	 58,439,000 
so my take-away:
1. your CMn isn't much better than the old ARM7TDMI;
2. unless you have a FPU, don't bother with floating point math;
3. even if you have a FPU, be careful about "double" math.

I don't have a CM7 to test (and my compiler doesn't support it anyway). Would be interesting to see relative performance here.
Post Reply

Return to “Off topic”