CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Pic-Pic Communication

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PhilB



Joined: 08 Feb 2006
Posts: 2

View user's profile Send private message

Pic-Pic Communication
PostPosted: Wed Feb 08, 2006 1:09 pm     Reply with quote

Hello all. I am trying my hand at some pic-pic communication using two 16f877 microchips. The send pic will send a string of characters that begin with a $ and is 21 characters long, + 1 for null. I was initially going to use a fgets() procedure to obtain the string in the receiving pic. Browsing the forum, I noticed that most suggest using the get_string() command instead.

My first question is: Can get_string() delineate between two rs-232 streams? The receive pic has two setup, one for pic-pic, the other for pc-pic.

Secondly, when I include input.c I continuously get compiler errors of the sort:

Code:
*** Error 48 "C:\Phil\PICC\drivers\input.c" Line 14(6,10): Expecting a (
*** Error 43 "C:\Phil\PICC\drivers\input.c" Line 14(13,14): Expecting a declaration
*** Error 43 "C:\Phil\PICC\drivers\input.c" Line 14(14,15): Expecting a declaration
*** Error 43 "C:\Phil\PICC\drivers\input.c" Line 14(16,17): Expecting a declaration
*** Error 48 "C:\Phil\PICC\drivers\input.c" Line 17(10,15): Expecting a (
*** Error 43 "C:\Phil\PICC\drivers\input.c" Line 21(4,6): Expecting a declaration
*** Error 43 "C:\Phil\PICC\drivers\input.c" Line 21(6,7): Expecting a declaration
*** Error 48 "C:\Phil\PICC\drivers\input.c" Line 21(7,12): Expecting a (


Thirdly, if I do get get_string() to work properly...what is the best interupt routine to use with it? #int_RDA, or #int_EXT (I have enough resources to use an enable pin).

Anyways, here is my code. My compiler is: CCS PCM C Compiler, Version 3.202.

Code:

#include <16F877.h>
#fuses HS, NOWDT, NOPROTECT, PUT, BROWNOUT, NOLVP
#use Delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, stream=sender, ERRORS)
#use rs232(baud=9600,parity=N,xmit=PIN_B6,rcv=PIN_B5, stream=PC,bits=8, ERRORS)


#include <input.c>

#define STRING_SIZE  22  // Allow up to 22 chars max (and 0 at end)

char input_str[STRING_SIZE];
char start;
boolean found_start;

#int_RDA
void RDA_isr(void) {
   if (fgetc(sender) == 0x24) {  // 0x24 == $
   get_string(input_str,STRING_SIZE);
    found_start = TRUE;
   }
 
}
         

main()
{
  enable_interrupts(INT_RDA);
  enable_interrupts(global);
  found_start = FALSE;
   while(1) {
      if (found_start) {
       fprintf(PC,"Received:  %s\n\r", input_str);
         found_start = FALSE;
      }
   
   }

}


Thanks for any help!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Feb 08, 2006 1:24 pm     Reply with quote

Don't do that. Use EX_SISR.C to create an interrupt-driven receive
buffer. Then in main(), create a loop which will use bkbhit() to see if
a char is available in the buffer. If so, then use bgetc() to get the char
from the buffer. Then use other code in main() to process the chars.
PhilB



Joined: 08 Feb 2006
Posts: 2

View user's profile Send private message

PostPosted: Thu Feb 09, 2006 8:36 am     Reply with quote

Thanks for the suggestion. I'll give it a try and see what i can do with it.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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