5 ms·
Side note for 2023: Some modern MCUs are low cost, but have FPUs. A good example is the STM32G4. So, unlike on an M0 MCU or w/e, you can freely use f32, if you
by the__alchemist 2y ago
Side note for 2023: Some modern MCUs are low cost, but have FPUs. A good example is the STM32G4. So, unlike on an M0 MCU or w/e, you can freely use f32, if you don't want fixed point. And you can get these for ~$1-2 / MCU.
That said... The G4 also has a hardware CORDIC peripheral that implements this algo for fixed-point uses. Is this mainly to avoid floating point precision losses? You program it using registers, but aren't implementing CORDIC yourself on the CPU; dedicated hardware inside the IC does it.
- kragen 2y agothe cheapest cortex-m4fs in stock on digi-key, trying to omit duplicates, are the 3-dollar nuvoton m481le8ae https://www.digikey.com/en/products/detail/nuvoton-technology-corporation/M481LE8AE/12337382 https://www.digikey.com/en/products/detail/nuvoton-technolog..., the 3-dollar maxim max32660 https://www.digikey.com/en/products/detail/analog-devices-inc-maxim-integrated/MAX32660GWE-T/8742640 https://www.digikey.com/en/products/detail/analog-devices-in..., and the 5-dollar atmel atsamd51 https://www.digikey.com/en/products/detail/microchip-technology/ATSAMD51G18A-MU/7390367 https://www.digikey.com/en/products/detail/microchip-technol.... their cheapest stm32g4 is the stm32g441kbt6 which rounds to 4 dollars https://www.digikey.com/en/products/detail/microchip-technology/ATSAMD51G18A-MU/7390367 https://www.digikey.com/en/products/detail/microchip-technol... where do you get them for under 2 dollars? (digi-key does list the nuvoton chip for barely under 2 dollars in quantity 500)
- the__alchemist 2y agohttps://jlcpcb.com/partdetail/Stmicroelectronics-STM32G431CBU6/C529356 https://jlcpcb.com/partdetail/Stmicroelectronics-STM32G431CB... JLC: $2.1 for qty=1. $1.3 at 1k qty. Loads of stock. It's a low flash and low RAM variant, but sufficient for some purposes. 170Mhz CPU with many onboard periphs.
- kragen 2y agofantastic, thanks!
- ddingus 2y agoThe second Parallax Propeller chip has a CORDIC engine in silicon. It's fast, and handles 64bit intermediate products, which makes the divide and trig stuff more than adequate precision for most things. One can always increase precision in software too. I was late to the game learning about CORDIC. I had used fixed point a lot in 8 and 16 bit assembly land for performance, and determinism. When I found out about it, I was stunned! It was fast, and only required basic math capability to be useful.
- djmips 2y agoI found that a lack of barrel shifter or at least micro-coded shift 'n' hampers Cordic in an 8 bit CPU but I coded a routine up for fun in 6502. I never found a use for it myself as there always seems to be a faster way to do things for games programming at least. https://forums.atariage.com/blogs/entry/3385-atan2-in-6502/ https://forums.atariage.com/blogs/entry/3385-atan2-in-6502/
- ddingus 2y agoYes a barrel shifter would have been a nice addition to the 6502. L Yes, general purpose code is rarely the answer. I think all of us see that after a while. Then, after that process, one starts coding differently. Chain stuff together, using common ops, pulling off intermediate values, etc... For most things, a fast way exists, but it will often be a tweak or two to make sense in the context.
- ddingus 2y agoI looked it over and frankly, I could not do better, or maybe even as good. Nice work!
- djmips 2y agoThanks!