CHECKING WHETHER RS 485 IS WORKING
Started by 8 years ago●8 replies●latest reply 8 years ago●768 views#include
#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.
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
Getting a serial link up and running is always a real pain in the behind. I've been in this embedded stuff for decades, and I still occasionally end up fumbling around for days getting one working.
Do you have an oscilloscope? If you're going to do serial stuff, a cheap USB O-scope will be all you need and will be a tremendous help. If that's not in your price range, I strongly suggest that you get a second RS-485 interface for your PC, and make sure you can get the two of them talking to each other. One of the special joys of serial interfaces is to flog device A for days when the real problem is on device B.