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

simple rs485 communication: rs458.c Error

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



Joined: 26 Apr 2010
Posts: 1

View user's profile Send private message

simple rs485 communication: rs458.c Error
PostPosted: Mon Apr 26, 2010 4:52 am     Reply with quote

I need help with rs485 communication.
In my system i have master device which is rs232-rs485 converter. I found the circuit from google and the schema is like this.

My slaves will be board with pic16f877A. The tx, rx pins from pic will connect to the 1st and 4th pin of the max485. in this circuit i didn't have to control RE, DE pins via PIC which make easy to program the slave pic

but still i have problem with CCS's built in rs485.c file.
i cant include into my project. I got this error.


my code
Code:

#include <16F877A.h>
#include <RS485.c>

#fuses HS, NOWDT
#use delay(clock=20000000)

void main()
{
   int deviceId = 0;
   if(input(PIN_B1))
      deviceId = 1;
   if(input(PIN_B2))
      deviceId = 2;
   if(input(PIN_B3))
      deviceId = 3;
   if(input(PIN_B4))
      deviceId = 4;
   if(input(PIN_B5))
      deviceId = 5;
   
   #define RS485_ID deviceId
   
   #define RS485_RX_PIN PIN_C7
    #define RS485_TX_PIN PIN_C6

   //defined but not using
   #define RS485_ENABLE_PIN   PIN_B7
   #define RS485_RX_ENABLE    PIN_B6 

   #define RS485_RX_BUFFER_SIZE  2

   int8 msg[RS485_RX_BUFFER_SIZE];

   rs485_init();

   while(true)
   {
      if(rs485_get_message(msg, true))
      {
         if(msg[0] == deviceId)
         {
            //do something
         }
      }
      //rs485_send_message(int8 to, int8 len, int8* data);


   }


}



and my second question: Am I really need this rs485.c file? In my case i didn't need control RE,DE pins.

i just want to send/rcv 2byte code from pics and receive/send 2byte from computer with acknowledgement
2byte = [1st byte: address, toggle bit] [2nd byte: command]

is it easy to do all of this with fputc(), fgetc() functions?
the rs485_init() function is too complex. there are interrups and ect. Do i need all this things?
Abdulla M.A.



Joined: 28 Mar 2010
Posts: 30
Location: Baghdad, Iraq

View user's profile Send private message Visit poster's website Yahoo Messenger

PostPosted: Thu Apr 29, 2010 10:43 am     Reply with quote

Where is the posts, who removed it????

Abdulla
_________________
"A scientist can discover a new star, but he cannot make one. He would have to ask an engineer to do that."
"For an optimist the glass is half full, for a pessimist it's half empty, and for an engineer is twice bigger than necessary."
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