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 to pic communication using uart
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
cheehow



Joined: 15 Sep 2010
Posts: 28

View user's profile Send private message

PostPosted: Mon Nov 08, 2010 10:17 am     Reply with quote

HI Everyone!!

I have written the code for this RS485, but in the code, there're required for pin B4 and B5 as RS 485 enable pin. So, in hardware circuit schematics. I don't have any idea to construct about it !! Please give me some guide. Your help would be appreciated!! thxs

Regards
Chee How
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Nov 08, 2010 10:14 pm     Reply with quote

Quote:

I have written the code for this RS485, but in the code, there're required
for pin B4 and B5 as RS 485 enable pin.
So, in hardware circuit schematics. I don't have any idea to construct
about it !! Please give me some guide.

See this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=28442
cheehow



Joined: 15 Sep 2010
Posts: 28

View user's profile Send private message

PostPosted: Wed Nov 10, 2010 9:32 am     Reply with quote

HI PCM Programmer,

i have one question. for the RS 232, what is the "stream" for ?? coz i saw some code put
#use rs232 ( baud rate=............, stream=pc);
is it communicate to the destination ? if i wanna communicate with the PIC microcontroller, is it put PIC there ??

Regards,
Chee How
cheehow



Joined: 15 Sep 2010
Posts: 28

View user's profile Send private message

PostPosted: Wed Nov 10, 2010 10:24 am     Reply with quote

Sorry for asking question here again ...

Now I meet some problem in the codes. The following are my codes:

Master:
Code:

#include <16F877A.h>
#fuses HS, NOWDT, NOLVP, NOBROWNOUT, NOPROTECT, PUT
#use delay(clock = 20000000)

#use rs232 (baud=9600, xmit=PIN_C6, rcv=PIN_C7, stream=PIC)
#define RS485_ID        0x11
#define RS485_USE_EXT_INT TRUE
#include <RS485.c>

void main()
{
     int data_received;
     
     rs485_init();

   while(True) 
   {

      rs485_wait_for_bus(FALSE);
     
      if (input(pin_b1))
      {
         rs485_send_message(0x12, 1, 3);
         output_high(PIN_b7);
         delay_ms(1000);
         output_low(PIN_b7);
         
      }
           
       if(rs485_get_message(data_received, FALSE))
      {

               if(data_received==6)
               {
                   output_high(PIN_b6);
                   delay_ms(1000);
                   output_low(PIN_b6);
               }
      }
   }
}

and the following are the slave codes:
Code:

#include <16F877A.h>
#fuses HS, NOWDT, NOLVP, NOBROWNOUT, NOPROTECT, PUT
#use delay(clock = 20000000)
#define RS485_ID  0x12
#define RS485_USE_EXT_INT TRUE

#include <RS485.c>

void main()
{
     int data_received;
     
     rs485_init();
     
     do
     {
         if(rs485_get_message(data_received, TRUE))
      { 
          if(dnata_received == 0x12)
          {
            output_high(PIN_B2);
            delay_ms(1000);
            output_low(PIN_B2);
          }
         
         rs485_wait_for_bus(FALSE);
         
         if(rs485_send_message(0x11, 1, 6))
         {
               output_high(PIN_B1);
               delay_ms(1000);
               output_low(PIN_B1);
         }
         
      }
     
     }
     while(true);
}

The problem is I can't detect where is the problem, because my hardware does not work. Can you all please check my codes see whether got any problem or not ... thxsss

My project is just like what I have said in previous, and it still not working. Hope to hear the good news soon. Your help would be appreciated.

Regards
Chee How
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Nov 10, 2010 12:46 pm     Reply with quote

Quote:
output_high(PIN_b7);
delay_ms(1000);
output_low(PIN_b7);

output_high(PIN_b6);
delay_ms(1000);
output_low(PIN_b6);

because my hardware does not work

You are using pins B6 and B7 for LEDs. These pins are used by the
ICD debugger/programmer. Don't use them for LEDs.

Post a link to a schematic of your hardware connections.
cheehow



Joined: 15 Sep 2010
Posts: 28

View user's profile Send private message

PostPosted: Thu Nov 11, 2010 9:27 am     Reply with quote

here is the link for my schematic diagram..
http://www.flickr.com/photos/briansiaw/5167023278/
tzehow_90



Joined: 28 May 2011
Posts: 3

View user's profile Send private message Send e-mail MSN Messenger

help
PostPosted: Tue Mar 05, 2013 1:18 pm     Reply with quote

I am new in using uart... can i have the circuit for connection between 2 pic for the coding above.... may i know wat we need to define and include during using uart.... thx very much
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Tue Mar 05, 2013 3:02 pm     Reply with quote

The answer should be an emphatic no.

Mike
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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