Helpful ReplyHot!XC16 : Convert Float To String

Page: < 12 Showing page 2 of 2
Author
karan123
Super Member
  • Total Posts : 482
  • Reward points : 0
  • Joined: 2009/02/02 11:11:21
  • Location: 0
  • Status: offline
Re: XC16 : Convert Float To String 2017/08/16 01:02:57 (permalink)
+1 (1)
Thanks
 
@KTrenholm
I have implement as below.

 
void ConvertFloattoLCDString(float FractionalNumber)
{
unsigned char LCDBuffer[10] ;
sprintf((char*)LCDBuffer,"%.2f",(double)FractionalNumber);
LCDString((char*)LCDBuffer) ;
}
 

Its Work..Below warning I am getting. 

 
main.c: In function 'ConvertFloattoLCDString':
main.c:158:2: warning: pointer targets in passing argument 1 of 'LCDString' differ in signedness main.c:84:6: note: expected 'unsigned char *' but argument is of type 'char *'
main.c:157:17: warning: Taking the address of 'LCDBuffer' may require an extended pointer for this device
 

 
 @CinziaG
Why so ? Why Complier is giving Warining ? I have latest plibs and XC16 Complier.
 
--
Karan
post edited by karan123 - 2017/08/16 01:14:11
#21
1and0
Access is Denied
  • Total Posts : 6760
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: XC16 : Convert Float To String 2017/08/16 01:25:57 (permalink) ☄ Helpfulby karan123 2017/08/16 02:45:15
+1 (1)

main.c:158:2: warning: pointer targets in passing argument 1 of 'LCDString' differ in signedness main.c:84:6: note: expected 'unsigned char *' but argument is of type 'char *'

Because the plain type 'char' is signed for the XC16 compiler, and your LCDString() accepts an 'unsigned char *' pointer.
 

main.c:157:17: warning: Taking the address of 'LCDBuffer' may require an extended pointer for this device

The compiler is just pointing out that an extended pointer (32 bits) instead of a normal pointer (16 bits) might be a better and safer option. That is, qualify the pointer with __eds__, and it should allocate 32 bits for it and should stop it from throwing this warning.
#22
karan123
Super Member
  • Total Posts : 482
  • Reward points : 0
  • Joined: 2009/02/02 11:11:21
  • Location: 0
  • Status: offline
Re: XC16 : Convert Float To String 2017/08/16 02:43:43 (permalink)
0
Thanks @1and0

The compiler is just pointing out that an extended pointer (32 bits) instead of a normal pointer (16 bits) might be a better and safer option. That is, qualify the pointer with __eds__, and it should allocate 32 bits for it and should stop it from throwing this warning.

How to use  __eds__ in code as written in  Msg #21?
 or
Where?

 
main.c: In function 'ConvertFloattoLCDString':
 
main.c:157:17: warning: Taking the address of 'LCDBuffer' may require an extended pointer for this device
 

 
--
Karan
post edited by karan123 - 2017/08/16 02:45:44
#23
CinziaG
rome burns :D
  • Total Posts : 2699
  • Reward points : 0
  • Joined: 2016/12/07 14:20:36
  • Location: Wien
  • Status: online
Re: XC16 : Convert Float To String 2017/08/16 03:19:29 (permalink)
0
Yep Smile
As for EDS, do you really need them? The pointer need the extra attribute, and if you have an array allocated in EDS you may need some "attribute(space(eds))" stuff , but I'm never exactly sure about them! (take a look at the map file)
#24
karan123
Super Member
  • Total Posts : 482
  • Reward points : 0
  • Joined: 2009/02/02 11:11:21
  • Location: 0
  • Status: offline
Re: XC16 : Convert Float To String 2017/08/16 04:09:25 (permalink)
0
But Something Like 
attribute(space(eds) char[10]={"TRY"};
on What ?
#25
1and0
Access is Denied
  • Total Posts : 6760
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: XC16 : Convert Float To String 2017/08/16 04:24:08 (permalink)
+1 (1)
It's time to RT-M.  Take a look to the "Extended Data Space Access" section in your XC16 User's Guide -- a copy should be located in your XC16 install folder.
 
#26
CinziaG
rome burns :D
  • Total Posts : 2699
  • Reward points : 0
  • Joined: 2016/12/07 14:20:36
  • Location: Wien
  • Status: online
Re: XC16 : Convert Float To String 2017/08/16 05:03:59 (permalink)
0
Smile
I had this, in an old software:
__eds__ WORD __attribute__((section("video"),eds,space(eds))) videoRAMR[VIDEO_BUFSIZE];


#27
Page: < 12 Showing page 2 of 2
Jump to:
© 2017 APG vNext Commercial Version 4.5