View previous topic :: View next topic |
Author |
Message |
karimpain
Joined: 15 Feb 2012 Posts: 39 Location: italia
|
Get a word using pic16f877a |
Posted: Mon Mar 05, 2012 1:52 pm |
|
|
Hello everyone! Can anyone please tell me how to obtain a word for example 'Heeey' from the rx of the pic using rs232 and depending on this word make a specific function. I programmed a pic using a single character with the specific job,but how can i do that using a word or more than one letter!!?!??!!?
in other words how to read a string not a character.
Thanks 4 reading |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Mon Mar 05, 2012 2:17 pm |
|
|
you get more than one character the same way you put on your pants.
One leg at a time. Or one character byte at a time if it is serial data .....
ideally with a character array, advancing a pointer to thr next place to PUT a receiver character as you go.
There are MANY examples of how to do this including using interrupts on
RX data ready - to help speed the plow for you. |
|
|
karimpain
Joined: 15 Feb 2012 Posts: 39 Location: italia
|
|
Posted: Mon Mar 05, 2012 2:36 pm |
|
|
Thanks but can you give me a link of a code or anything else!! |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Mon Mar 05, 2012 2:46 pm |
|
|
there is a wonderful buffered example for getting LOTS of characters into a buffer string called EX_SISR.C , found
in your CCS examples folder
plenty of guidance there on your exact problem. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Mon Mar 05, 2012 2:59 pm |
|
|
press F11 when your project is open |
|
|
karimpain
Joined: 15 Feb 2012 Posts: 39 Location: italia
|
|
Posted: Mon Mar 05, 2012 6:34 pm |
|
|
thanks, i m going to take a look. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Mar 05, 2012 7:34 pm |
|
|
Look at the get_long() function in the input.c file:
Quote: |
c:\program files\picc\drivers\input.c
|
Here are two CCS example files that show how to use get_long():
Quote: |
c:\program files\picc\examples\ex_pll.c
chan_num = get_long();
c:\program files\picc\examples\ex_malloc.c
num = get_long();
|
To use get_long(), you should connect your PIC board to your PC with
an RS-232 cable. Then open a terminal window on your PC, by using
a program such as TeraTerm. You can type in any number in the
range from -32768 to 32767. You must press the Enter key when done
typing the number. The get_long() function will get the number and
convert it to a 'signed int16' value and you can save it in a variable
in your PIC program. |
|
|
|