[En-Nut-Discussion] Ethernut II RS485 Communication
Zheng Anding
adzheng at yahoo.com
Wed May 12 21:17:46 CEST 2004
Hello, All,
I'm a software guy and new to Ethernut. I just bought a Ethernut II board and try to use UART1 as a 485 master to scan data from my another board which has been tested successfully as a 485 slave.
First I followed the Hardware Manual and setup JP1 (shorten Pin1 & 2, 3 & 4, 9 & 10, 11 & 12), JP2 (shorten Pin1 & 2, 3 & 4) and JP6 (shorten Pin 5 & 6, 7 & 8, Pint 9 & 10). Then I just directly connected RS485A to the High (+) of my slave 485 and RS485B to the Low (-) of my slave 485. Then I modified the uart.c which is a sample comes with Ethernut software. Here is a slice of the code:
/*********************************************************************************
static unsigned char SendBuf[5] = {0x96, 0x96, 0x01, 0x00, 0x01};
static unsigned char ReceiveBuf[32] = {0};
int got;
FILE *uart1;
u_long baud1 = 9600;
NutRegisterDevice(&devUart1, 0, 0);
uart1 = fopen("uart1", "r+");
_ioctl(_fileno(uart1), UART_SETSPEED, &baud1);
_write(_fileno(uart1), SendBuf, 5);
_write(_fileno(uart1), 0, 0);
NutSleep(500);
got = _read(_fileno(uart1), ReceiveBuf, sizeof(ReceiveBuf));
**************************************************************************************/
But I cann't get anything from my slave device so far. My questions are:
1. Is there anything special for the hardware setting? Did I setup my board correctly?
2. I knew the 485 on Ethernut is half duplex and have to use PD5 / PD4 to control the data direction, but based on Nut/OS, do I still need to do this? Is there any existing RS-485 UART driver for Nut/OS now?
3. If the above answer is NO, do I have to wirte ISR for Mega128 to send and receive package?
Thanks for any kindly help.
Sincerely,
Alex
---------------------------------
Do you Yahoo!?
Yahoo! Movies - Buy advance tickets for 'Shrek 2'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.egnite.de/pipermail/en-nut-discussion/attachments/20040512/c62115f6/attachment-0001.html>
More information about the En-Nut-Discussion
mailing list