## CHECKING WHETHER RS 485 IS WORKING

Started by 6 years ago8 replieslatest reply 6 years ago204 views
Inorder  to check my rs 485 port,i had connected my lpc2378 (rs485) with my PC through ADAM-4561(1 port isolated USB to RS 232/422 485converter).Now how to check it and where to check it?????.i am very new to microprocessor development and am still figuring out the way things work on the LPC2378 . So up front apologies for "stupid" questions.i had done the programing.First time iam doing code with rs 485.

#include <LPC23xx.H>

#include <stdio.h>
int main (void)
{

PCONP |= (1<<3)                       /* power for uart 0 */
PINSEL0 |= 0x00000050;                /* Enable TxD0 *//* Enable RxD0 */
U0LCR = 0x83;                         /* 8 bits, no Parity, 1 Stop bit */
U0DLM = 0x00;
U0DLL = 0x78;                           /* 9600 Baud Rate @ 12MHz Clock */
U0FDR = 0xA3;
U0LCR = 0x03;                          /* DLAB = 0 */
U0FCR = 0x81;

while(1)
{
FIO2SET|=(1<<2);               /*TRANSMIT MODE*/
U0THR = 'A';
while (!(U0LSR & 0x40));
FIO2CLR|=(1<<2);
while (!(U0LSR & 0x01));
data1 =U0RBR;
}


Is my code correct,if not please help me with changes. how to know whether my code is working using hyperterminal .please provide valuable suggestions.
[ - ]

May I ask why you posted the same question twice today in this forum?

[ - ]

Please find the changes that I had from the previous question.In order to make my question more clear I posted it twice.

[ - ]
RS485 is half duplex in your case (you have connected /RE and DE). So you either transmit or receive, but you can't try to echo yourself to check if it works.

The only way to test the code is to have another RS485 test device on the other side sending data.

About your code : this forum is about DSP, not microcontrollers. I am afraid that you will not get a code review from here (and moreover, I have to say that the description of your problem is not clear. You probably know what you talk about, but from here, it's not clear - at least for me)

Benoit

[ - ]

Hi Benoit,

the OP didn't post on DSPRelated, something weird happened with the forum platform that made the post appear on EmbeddedRelated AND DSPRelated.  Still trying to figure out the problem, fist time it happened in a year!

Stephane

[ - ]

And here I was wondering if you'd made a cross-posting feature!

[ - ]

Haha, no but I might implement this in the near future, but it will be only for highly trusted users like you to use.

[ - ]

AJ

RS485 communication is in essencee UART communucation with an enable signal. To transmit, make P2.2 high and send data through UART.

For reception, P2.2 must be low. If you have a converter on the PC side, use any terminal emulator like Docklight, Teraterm etc.

If you have further queries, you are welcome.

Regards

jkvasan

[ - ]