Joined: 14 Feb 2007 Posts: 46 Location: Greece & Cyprus
How to send long value over USART??
Posted: Thu Jan 31, 2008 1:57 pm
HI
I'm working a project need to send long value numbers serialy.
Does any one now how can i sent long value over Usart ??
Let's say i whant to sent a number 1234.12 how can i do this?
putc() , fputc() send only character ,So how do i sent Long Value?? _________________ ---- GREECE ----
E_KARVELAs
Joined: 14 Feb 2007 Posts: 46 Location: Greece & Cyprus
Posted: Thu Jan 31, 2008 2:07 pm
Need to send From PIC micro to PIC micro.
Not PIC TO PC.
thanks _________________ ---- GREECE ----
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
Posted: Thu Jan 31, 2008 3:35 pm
If you just want to send a 16 bit long you can use make8() and make16() to break the long into bytes. A number like 1234.12 is a float which requires make32() to reconstruct.
Or you can use printf() and maybe gets() to send the number as a string. _________________ The search for better is endless. Instead simply find very good and get the job done.
E_KARVELAs
Joined: 14 Feb 2007 Posts: 46 Location: Greece & Cyprus
Posted: Fri Feb 01, 2008 7:44 pm
SherpaDoug wrote:
If you just want to send a 16 bit long you can use make8() and make16() to break the long into bytes. A number like 1234.12 is a float which requires make32() to reconstruct.
Or you can use printf() and maybe gets() to send the number as a string.
HI
I found this in the compiler :
Code:
main() {
char string[20];
float f;
f=12.345;
sprintf(string," \f % 6.3 f ", f );
//in this case string[20] contein the float but coverted into char
}
Question!!!
getc() or fgetc()return a character.
What does the fgets() return from usart ???
didn't figure it out .
thanks _________________ ---- GREECE ----
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum