RS 485 + komunikacni protokol ?

Petr Stehlík petr.stehlik
Středa Březen 17 11:53:20 CET 2004


Stejnym spusobem jak je uvedeno dale jsem to vyresil pred 5roky v Qbasicu
a chodilo to spolehlive bez  problemu ze strany UARTu v PC.

----- Original Message -----
From: Straka Matus <magpie@pobox.sk>
To: Multiple recipients of list <hw-news@list.gin.cz>
Sent: Saturday, April 08, 2000 12:15 PM
Subject: RE: RS 485 + komunikacni protokol ?


> > >
> >
> > Haluz ne, jen draze zaplacene poznani. Skuste poslat prvni bajt s
natvrdo
> > nastavenou paritou na 1 a druhy s paritou v 0.
>
> No nizsie v maile su zdrojaky v C, ktorymi to realizujem. Na konci
seriovej
> linky je 8051 v MultiCPU rezime a funguje mi to. Ovsem prenosove medium je
> kabel.
>
> > protokol, treba jiz nekolikrat zminovany ProfiBus,
> > a budu mit jistotu, ze to procpu dratama, TV rozvodem, vzduchem, modemem
a
> > pripadne temer cimko-li jinym.
>
> O tom niet pochyb. V pripade, ze chceme pouzit este nejaky medziclanok,
> naozaj nam neostane nic ine ako pouzit "standardny" protokol.
>
> A teraz tie spomenute zdrojaky:
>
> #define PORT1 0x2F8  /* Port Address Goes Here */
> #define INTVECT 0x0B /* Com Port's IRQ here (Must also change PIC setting)
> */
>
> /* Defines Serial Ports Base Address */
> /* COM1 0x3F8                        */
> /* COM2 0x2F8        */
> /* COM3 0x3E8        */
> /* COM4 0x2E8        */
>
> void send_address(unsigned char b)
> {
> outportb(PORT1 + 3 , 43);  /* 8 Bits, Mark Parity , 1 Stop Bit */
> /* 101011B */
> outportb(PORT1, b); // Send address
> delay(3);
> }
>
> void send_data(unsigned char p)
> {
> outportb(PORT1 + 3 , 59);  /* 8 Bits, Space Parity, 1 Stop Bit */
> outportb(PORT1, p); // Send Data
> delay(3);
> }
>
>
>
>
>
> void main()
> {
> outportb(PORT1 + 1 , 0);        /* Turn off interrupts - Port1 */
> oldport1isr = getvect(INTVECT); /* Save old Interrupt Vector of later
> recovery */
> setvect(INTVECT, PORT1INT);     /* Set Interrupt Vector Entry */
> /* COM1 - 0x0C */
> /* COM2 - 0x0B */
> /* COM3 - 0x0C */
> /* COM4 - 0x0B */
> outportb(PORT1 + 3 , 0x80); /* SET DLAB ON */
> outportb(PORT1 + 0 , 0x18);  /* Set Baud rate - Divisor Latch Low Byte */
> /*         0x06 =  19,200 BPS */
> /*         0x0C =   9,600 BPS */
> /*         0x18 =   4,800 BPS */
> /*         0x30 =   2,400 BPS */
> outportb(PORT1 + 1 , 0x0);     /* Set Baud rate - Divisor Latch High Byte
> */
> outportb(PORT1 + 3 , 0x03);     /* bolo 0x03, 8 Bits, No Parity, 1 Stop
Bit
> */
> outportb(PORT1 + 2 , 0xC7);     /* FIFO Control Register */
> outportb(PORT1 + 4 , 0x0B);     /* Turn on DTR, RTS, and OUT2 */
> outportb(0x21,(inportb(0x21) & 0xF7));  /* Set Programmable Interrupt
> Controller */ /* COM1 (IRQ4) - 0xEF  */
> /* COM2 (IRQ3) - 0xF7  */
> /* COM3 (IRQ4) - 0xEF  */
> /* COM4 (IRQ3) - 0xF7  */
> outportb(PORT1 + 1 , 0x01);     /* Interrupt when data received */
> ..
> ..
> ..
> atd.
> }
>
> Matus Straka
>







Další informace o konferenci Hw-list