- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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:
int*status;
LCD_PrString(ftoa(Voltage,status));
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:
int status;
LCD_PrString(ftoa(Voltage,&status));
I did not check for similarities in other projects that used ftoa yet, but it may be worth checking for.
Happy coding
Bob
- Labels:
-
PSoC 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I do not know why the system assumes me to be "WeiBiao". I did not change my name, I'm still "Bob". Where do I get the 10 redeem points from that are due to me?
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The real WeiBaio would be happy to get extra 10 points. 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It is not much he will get for 110 points, so he may keep them.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
One can get a T-shirt for 100 points. Not bad.