|
|
View previous topic :: View next topic |
Author |
Message |
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
Problem with RS485 |
Posted: Mon May 19, 2014 5:57 am |
|
|
Greatings! I`m trying to connect 2 PIC18F2550 through RS485. I`m using sn75176b as RS485 transceiver. So I`ve connected PIN_C7 to pin1 of the sn75176b(R).
PIN_C6 - > pin 4(D)
PIN_b0 -> pin 2 (RE)
PIN_B1 -> pin 3 (DE)
I have 10k resistor between every pin and Vcc. The problem is I can`t pass the rs485_init(); procedure. The program stops on this row :
#use rs232(baud=9600, xmit=RS485_TX_PIN, rcv=RS485_RX_PIN, enable=RS485_ENABLE_PIN, bits=9, long_data, errors, stream=RS485)
I`ve removed the multimaster directive from the down row because the compiler doesn`t liked it.
Can you tell where to look for the problem?!
Thanks!
PP: The controller is working. I`ve made a blink test and the frequency is correct! |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Mon May 19, 2014 6:17 am |
|
|
got code and compiler version ? |
|
|
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
|
Posted: Mon May 19, 2014 7:32 am |
|
|
Compiler version 4.134, MPLab 8.91.
Here is my master code:
Code: |
#include <18F2550.h>
#device *=16
#fuses NOWDT,CPUDIV1
#use delay(clock=7372862)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, stream=PC)
#define RS485_RX_BUFFER_SIZE 64
#define RS485_USE_EXT_INT TRUE
int8 OUR_RS485_ID = 0;
#define RS485_ID OUR_RS485_ID
#include <rs485.c>
#include <stdlib.h>
int8 in_char = 0;
#INT_RDA
void serial_isr()
{
in_char = fgetc(PC);
}
void main()
{
rs485_init();
while(1)
{
delay_ms(10);
}
}
|
The program never reaches the main loop(delay_ms(10)). It stops o this row
#use rs232(baud=9600, xmit=RS485_TX_PIN, rcv=RS485_RX_PIN, enable=RS485_ENABLE_PIN, bits=9, long_data, errors, stream=RS485)
It seems it can`t define the uart. I don`t know why...
Do you need anything else? I can post the settings in the RS485 file, but I don`t think I`ve made a mistake there. I just changed the pins!
Thanks! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19589
|
|
Posted: Mon May 19, 2014 7:59 am |
|
|
The setting:
#define RS485_USE_EXT_INT TRUE
Means that the RS485 RX pin _must_ connect to the INT_EXT pin, but you show this pin as being used for receive enable.....
Read the comments inside the RS485.c file |
|
|
|
|
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
|