cancel
Showing results for 
Search instead for 
Did you mean: 

Type conversions

carnett1
Associate II
Posted on November 22, 2010 at 19:15

I am using the STM8S-discovery card and I want to convert a long to a floting point and also a float or double to an ASCII  string.  If I use a very common conversion such as atof to convert a string to a float it cannot find the prototype.  I cannot even convert an integer to a string.  I kknow some compilets will nt convert a string to a float which I could conver my float to a long and manually place my decimal point but where do I find the file for simple convversions to include in my workplace or as an include in main.c

charles

4 REPLIES 4
carnett1
Associate II
Posted on November 22, 2010 at 22:28

I tried using int2str in hkykper terminal but it didn't add null.  I added null but it does't work.  I am using cosmic.  anyone know what is wrong with cosmic's code?

charles

Andrew Neil
Evangelist
Posted on November 23, 2010 at 15:11

''I tried using int2str in hkykper terminal''

 

What do you mean by that?

Hyperterminal is just a terminal program on a PC - it doesn't have any ''int2str'' feature
carnett1
Associate II
Posted on November 24, 2010 at 00:44

I mean hyperterminal.c in cosmic IDE.  Using the sample hyperterminal program supplied by STM for STM8S-discovery prototype board.  In hyperterminal.c there is the function int2str which is suppose to convert an interger (u32) to a string.  It doesn't work.  I notice a big discrepancy when I sent the string to hyper terminal on the PC.  So I put in a break point and using watch point examined str[x] where x went from 0 to 5.  It revealed the same as the PC.   Has int2str been corrected or what is the corrected code? Or is there some other function that I should be using.  ie. I put in the u32 integer of 22 and the first byte n the string was ox68.

charles

Andrew Neil
Evangelist
Posted on November 24, 2010 at 08:39

''I mean hyperterminal.c in cosmic IDE''

 

Then you really need to say exactly that!

Being able to clearly & precisely state things is key to any kind of software development.

But note that this has nothing specifically to do with Cosmic or any other IDE - the example (including its source code) is written by ST.

''In hyperterminal.c there is the function int2str''

 

 

No, there isn't.  Look again, carefully - remembering that the 'C' programming language is case sensitive...

''Has int2str (sic) been corrected''

 

 

Apparently not!

If you search through that whole example project, you will find that Int2Str is never called - so, presumably, it has never been tested!

See:

[DEAD LINK /public/STe2ecommunities/mcu/Lists/STM8SDiscovery/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM8SDiscovery/HyperTerminal example re-work&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000CCDF802E596CAF44ADED5E61F5CA8B1B&TopicsView=https://my.st.com/public/STe2ecommunities/mcu/Lists/STM8SDiscovery/AllItems.aspx&currentviews=259]https://my.st.com/public/STe2ecommunities/mcu/Lists/STM8SDiscovery/Flat.aspx?RootFolder=%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fSTM8SDiscovery%2fHyperTerminal%20example%20re%2dwork&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000CCDF802E596CAF44ADED5E61F5CA8B1B&TopicsView=https%3A%2F%2Fmy%2Est%2Ecom%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2FSTM8SDiscovery%2FAllItems%2Easpx&currentviews=259

''Or is there some other function that I should be using''

 

 

What function, usually mentioned in the 1st chapter of any book on 'C', can be used for creating formatted output...?