View previous topic :: View next topic |
Author |
Message |
cheehow
Joined: 15 Sep 2010 Posts: 28
|
|
Posted: Mon Nov 08, 2010 10:17 am |
|
|
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
|
|
Posted: Mon Nov 08, 2010 10:14 pm |
|
|
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
|
|
Posted: Wed Nov 10, 2010 9:32 am |
|
|
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
|
|
Posted: Wed Nov 10, 2010 10:24 am |
|
|
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
|
|
Posted: Wed Nov 10, 2010 12:46 pm |
|
|
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
|
|
|
tzehow_90
Joined: 28 May 2011 Posts: 3
|
help |
Posted: Tue Mar 05, 2013 1:18 pm |
|
|
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
|
|
Posted: Tue Mar 05, 2013 3:02 pm |
|
|
The answer should be an emphatic no.
Mike |
|
|
|