Content originally posted in LPCWare by Rob65 on Tue Nov 15 00:08:33 MST 2011
Quote: Zero
I don't like storing data in MCU flash since EEPROM (smaller, SOT23-5) / FRAM (faster, SO8) / RTC (NV-RAM) is able to store my data :rolleyes:
But that means adding extra components so this votes yeah for storing data in Flash :eek:
One very good reason for not storing data in flash is that you will loose this data when reprogramming your flash with a new software version. Meaning that you have to recalibrate - something you don't want in a running product.
I calibrate my hardware before final assembly. Calibration is done using a separate test program that also tests the other hardware interfaces on the board.
This may sound like something only being used in a real production line but I even use this for my (sometimes just one off) prototypes: After my hardware is done (sometimes a real PCB, sometimes a perfboard with my module on top) I start writing a basic program that verifies all (hardware) connections; are all my keys connected to the correct I/O lines, do LEDs/motors/relays etc. act as expected, are the A/D and D/A interfaces getting the correct data, etc.
Very useful - it saved me quite some time looking for bugs in my code where the problem was in the hardware :D
Quote: BPC
I can't seem to figure out how to convert a float to a string properly (without using sprintf) ...
Why not (try to) use fixed point. I.e. instead of using a float with the value 234.678 use an integer with the value 234678. This does limit you in the kind of calculations you can do but in the end it saves a lot of memory and processing time.
The trick is to start thinking fixed point bottom up. If this is an A/D value you want to convert with a 3.222 mV step (3.3 / 1024) and you want the value in mV, the floating point way would be to multiply by 3.222. Instead multiply by 3222 [uV] (integer) which will give you the value in uV and then divide by 1000. Always (really always) check for overflow on your 32 bits integer; in this case intermediate results will never be larger than 3,300,000
Quote:
... and without rounding off my numbers
We are always rounding off numbers ...
Floating point numbers have only 6-9 significant decimals. The problem is that you never know when rounding will take place.
In this case (A/D conversion) I specify my calibration value in uV and do all calculations in uV - there is no way for me to reach a higher accuracy with the calibration equipment I have.
Rob