Programming Mistake in PSoC1 Example Project | Cypress Semiconductor
Programming Mistake in PSoC1 Example Project
In the PSoC1 example project CE82235 is hidden an ugly programming error.
The project reads an ADC voltage, converts it to a float number and displays the result on the LCD. Part of this conversion is ussing ftoa(). The declarations are as follows:
Though this is syntactically correct, the author did not follow the usual C-linkage needed. Sinc C only knows "reference by value" for parameters, it is required to specify the address for a parameter that is used to give back a value (like the staus).
Since the *status" is not initialized within the project it is pointing into electronic nirwana giving unpredictable results (modifying memory address zero and one(1)).
What should have been written was:
I did not check for similarities in other projects that used ftoa yet, but it may be worth checking for.