Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC C CCS:simple rs485 communication: rs458.c Error

Status
Not open for further replies.

nergiz87

Newbie level 4
Joined
Mar 29, 2010
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,341
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.
swdytv.jpg

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.
29wk1du.jpg


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?
 

in case of rs485 u have to control RE,DE pin.

all you have to do join both pin and connect to PIC pin. in normal mode RE,DE = 0 that time u are in RX mode. in case of transmit the data make RE,DE=1 send your data and get back in to RX mode ie. RE,DE=0

Regards.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top