Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
09/16/07 09:03
Read: times


 
#144661 - RS-485 code
Responding to: ???'s previous message
Hi all
Just deciding using RS-485 fullduplex with
mode 3 serial port(multiprocessor)
The AT89S52 or DS89C450 as slave processor


$INCLUDE (reg_c51.INC)
echo BIT 20H; echo enable bit
TxOK BIT 21H; software flag
org 000h
ljmp begin
org 23h
ljmp serial_IT
/**
* FUNCTION_PURPOSE: This file set up uart in mode 3 (9 bits uart) with
* timer 1 in baud rate generator mode.
* FUNCTION_INPUTS: void
* FUNCTION_OUTPUTS: void
*/
org 0100h
begin:
MOV SCON, #0F0h; /* uart in mode 3 (9 bit), REN=1 */
MOV SADDR,#03h; /* local address */
MOV SADEN,#0FFh; /* address mask */
ORL TMOD, #20h; /* Timer 1 in mode 2 */
MOV TH1, #0FDh; /* 9600 Bds at 11.059MHz */
MOV TL1, #0FDh; /* 9600 Bds at 11.059MHz */
SETB ES; /* Enable serial interrupt*/
SETB EA; /* Enable global interrupt */
SETB TR1; /* Timer 1 run */
loop:
JNB echo,$; /* wait data to echo */
CLR echo ; /* disable echo */
SETB TB8; /* address mode */
SETB TxOK; /* set software flag */
MOV SBUF,#01h; /* send master adress */
JB TxOK,$; /* wait the stop bit transmition */
CLR TB8; /* data mode */
SETB TxOK; /* set software flag */
MOV SBUF,A; /* send data */
JB TxOK,$; /* wait the stop bit transmition */
LJMP loop

;/**
; * FUNCTION_PURPOSE: serial interrupt, echo receive data to master
; * FUNCTION_INPUTS: P3.0(RXD) serial input
; * FUNCTION_OUTPUTS: none
; */
serial_IT:
JNB TI,END_Test_TI; /* if reception occur */
CLR TI; /* clear transmition flag for next transmition
*/
CLR TxOK; /* clear software transmition flag */
END_Test_TI:
JNB RI,END_Test_RI; /* test if it is a reception */
CLR RI; /* clear reception flag for next reception */
JNB RB8,address_mode
CLR SM2; /* go into data mode */
LJMP END_Test_RB8
address_mode:
MOV A,SBUF; /* Read receive data */
SETB SM2; /* return into address mode after receive data */
SETB echo
END_Test_RB8:
END_Test_RI:
RETI
end

from Atmel uart application note


Is the code above for fullduplex slave?

Thank's
JBJ

List of 46 messages in thread
TopicAuthorDate
MCS-51 and RS485            01/01/70 00:00      
   Specifics?            01/01/70 00:00      
   not enough clear            01/01/70 00:00      
   RS485 code at code library didn't work's            01/01/70 00:00      
   .ASM or .C code nevermind            01/01/70 00:00      
      But what do you need it to do?            01/01/70 00:00      
         485 master slave            01/01/70 00:00      
            I did            01/01/70 00:00      
               RS-485 master/slave code.            01/01/70 00:00      
                  Try Modbus            01/01/70 00:00      
                     Oops sorry,Must using uart with another mode.            01/01/70 00:00      
   RS-485 code            01/01/70 00:00      
      Full duplex?            01/01/70 00:00      
         Full duplex ...the reasons            01/01/70 00:00      
            That's not a reason!            01/01/70 00:00      
            Technically            01/01/70 00:00      
               another reason            01/01/70 00:00      
                  maybe You need Ethernet?            01/01/70 00:00      
                     Another issue...            01/01/70 00:00      
                  wrong? not really, but wasteful            01/01/70 00:00      
                  another reason 2            01/01/70 00:00      
                     there is no 'same time'            01/01/70 00:00      
                        OK there wasn't same but....            01/01/70 00:00      
                           Asynchronous?            01/01/70 00:00      
                           if I understand what you are saying            01/01/70 00:00      
                              Something like this            01/01/70 00:00      
                                 Modbus            01/01/70 00:00      
                                    swicth to modbus            01/01/70 00:00      
                                       Sample code            01/01/70 00:00      
                                    References            01/01/70 00:00      
                                 collisions            01/01/70 00:00      
   try 30 baud            01/01/70 00:00      
   Before jumping to pool named as "modbus"            01/01/70 00:00      
      You have a calculator!            01/01/70 00:00      
         what a waste of bandwith            01/01/70 00:00      
            Tradeoff            01/01/70 00:00      
               There is overhead you can save with no ill effect            01/01/70 00:00      
                  The point is...            01/01/70 00:00      
                     modbus exist does not make it pantyhose            01/01/70 00:00      
                        For a beginner...            01/01/70 00:00      
   Getting wet with modbus by drag from Russel            01/01/70 00:00      
   AT89S8252 and AT89S52            01/01/70 00:00      
      Nope!            01/01/70 00:00      
         AT89S5X with 24LC02            01/01/70 00:00      
            Lot of work??            01/01/70 00:00      
            Quoting previous posts            01/01/70 00:00      

Back to Subject List