|
|
View previous topic :: View next topic |
Author |
Message |
guest Guest
|
doubt on RS232 |
Posted: Thu Mar 03, 2005 3:04 pm |
|
|
hi everyone,
I am student working on my project using PIC. I dont have any exposure to PIC, and not much experience with C either. But I thought working in C would be easier than working with Assembly language.
I have a doubt about data transmission through RS232.
I would like to know, what exactly printf or putc does.
suppose for example,
if I am writing
putc('c');
i suppose that its sending the ASCII value of c i.e., 99 through RS232.
What will it send if I use printf("%2Lx",a);
where a is some hexadecimal integer and its value is 0xAA.
What would be sent through RS232?
Suppose if I connect two PICs using RS232, can I directly store the received value(sent as hex number at sending end), in an integer variable, or need to perform some conversions to get the proper hexadecimal values.
Thanks for any help
KS |
|
|
rwyoung
Joined: 12 Nov 2003 Posts: 563 Location: Lawrence, KS USA
|
|
Posted: Thu Mar 03, 2005 3:37 pm |
|
|
1) Go buy or borrow a copy of Kernigahn and Ritchie's "The C Language", second edition. Read it, understand it.
1.5) Go find a copy of the Dev-C++ environment (Bloodshed) and install it on your PC. Should be versions for both Windows and Linux. Now you have something to play with while reading the K&R book and you can printf(), fprintf(), putc() etc to your heart's content until you understand what the functions do.
2) Realize that a PIC is different architecture than a x86 or 680xx or other "big iron" microprocessors you might program in C so what may look good in ANSI C, may not be possible to do with the CCS compiler and a PIC. It may take a little finese.
3) Read the datasheet for the PIC you have picked. If you haven't picked a PIC, at least read the PIC16F877A or PIC18F452(0) datasheets.
printf("%2Lx",a); where a=0xAA should send out two ASCII 'A's
If you are going to send data from one PIC to another, remember bytes are bytes are bytes. Send 0xBC using putc() and you will get 0xBC on the other end. _________________ Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month! |
|
|
|
|
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
|
Powered by phpBB © 2001, 2005 phpBB Group
|