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

RS232 and RS485 working together ?

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







RS232 and RS485 working together ?
PostPosted: Tue Mar 20, 2007 6:16 am     Reply with quote

Hello everybody.

I am using PIC 18F2455 as a master to communicate with numerous 16F690.
My first step is to configure the 18F and try sending some data on RS485 line

il watch with an oscilloscoppe , see that data are transmited.

I activate the RS232 , that i connected to a PC for debugging, The PC receive the RS232 data , and print them well on my Screen.

But RS485 do not work any more. Is there something in the hardware of software that avoid them to work together, or i did something wrong ?

I use the RS485.c
with the default Pins
Code:

#if(RS485_USE_EXT_INT == FALSE)
   #ifndef RS485_RX_PIN
   #define RS485_RX_PIN       PIN_C7   // Data receive pin
   #endif

   #ifndef RS485_TX_PIN
   #define RS485_TX_PIN       PIN_C6   // Data transmit pin
   #endif

   #ifndef RS485_ENABLE_PIN
   #define RS485_ENABLE_PIN   PIN_B4   // Controls DE pin.  RX low, TX high.
   #endif

   #ifndef RS485_RX_ENABLE
   #define RS485_RX_ENABLE    PIN_B5   // Controls RE pin.  Should keep low.
   #endif

   #use rs232(baud=9600, xmit=RS485_TX_PIN, rcv=RS485_RX_PIN, enable=RS485_ENABLE_PIN, bits=9, long_data, errors, stream=RS485)
   #use rs232(baud=9600, xmit=RS485_TX_PIN, rcv=RS485_RX_PIN, enable=RS485_ENABLE_PIN, bits=9, long_data, force_sw, multi_master, errors, stream=RS485_CD)


and i activate RS232 like this
Code:


   #if defined(_DEBUG_RS232)
      #use rs232(baud=9600,parity=N, xmit=PIN_B1, rcv=PIN_B0, bits=8,stream=DEBUG)
   #endif
   
   #define RS485_ID  1                 // The device's RS485 address or ID
   #define RS485_USE_EXT_INT FALSE        // Select between external interrupt
   #define RS485_RX_PIN       PIN_C7   // Data receive pin
   #define RS485_TX_PIN       PIN_C6   // Data transmit pin

   #include "RS485.c"


As you can see i uses differents pins for RS232 and RS485
Any advice ?
thanks
Cookie
Guest







PostPosted: Wed Mar 21, 2007 3:29 am     Reply with quote

any help ?

Only thing i need is to know, if i could work , or it cannot. SO i can avoid loosing time trying to make something work that is impossible!


Thanks
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Wed Mar 21, 2007 5:15 am     Reply with quote

Well, you show us only the header pin definitions, but we didn�t see your code.
As long as I understand, your architecture is:
1 Master that comunicate with n Slaves through RS485 and the same Master comunicate
with a PC through RS232, is this ok? If this is the case, of course it should work, the Master
is who handle the whole communications timmings.

Just a comment with your code:
Code:

#ifndef RS485_ENABLE_PIN
   #define RS485_ENABLE_PIN   PIN_B4   // Controls DE pin.  RX low, TX high.
   #endif

   #ifndef RS485_RX_ENABLE
   #define RS485_RX_ENABLE    PIN_B5   // Controls RE pin.  Should keep low.
   #endif

There is a risk of bus contention and is code dependant. Usually I keep tied together PIN2
and PIN3 of the RS485 transceiver (unless you use Full Duplex) and control both pins with
a single PIC output.


Humberto
Cookie
Guest







PostPosted: Wed Mar 21, 2007 8:35 am     Reply with quote

thank you for your anwer.
I make it work, you have to include the RS485.c file BEFORE declare use of rs232. If i do the other way it do not work.

strange ...

thanks for your concern Humberto.
Guest








PostPosted: Sat Apr 21, 2007 4:12 am     Reply with quote

whats your compiler version Cookie
funmix



Joined: 27 Mar 2007
Posts: 33

View user's profile Send private message

PostPosted: Sun Apr 22, 2007 8:55 pm     Reply with quote

HI cookie,

do you mind to share your working code?
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