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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/04/09 22:14
Read: times


 
#164335 - Give this a try...
Responding to: ???'s previous message
;Idea of how to send DMX-bytes at 250kBds and receive MIDI-bytes at
;31.25kBds at the same time. An AT89S52 is used at 24MHz clock speed.

;UART is running in Mode 1, which means that 1 start bit, 8 data bits
;and 1 stop bit is used. This is directly compatible with MIDI data
;transmission. DMX uses one additional stop bit, which is fabricated
;here by an additional delay.

;Timer 1 is used for the receiving clock, Timer 2 for the transmit clock.
;There are 128 DMX-bytes assumed to be sent as a string. These bytes
;are assumed to be sitting in indirect RAM of micro at addresses
;128...255.
;As up to about 80 MIDI-bytes might be received during the transmission
;of DMX-bytes, these MIDI-bytes are stored in RAM of micro at addresses
;32 up.  

;The DMX transmission starts with a BREAK (>=88µsec), followed by a
;MARK (>=8µsec) and a START byte (=44µsec). Then, 128 DMX data bytes are
;transmitted. Between the individual DMX data bytes pauses are allowed,
;which can be used to poll the receive interrupt flag (RI). If set, the
;DMX transmission is halted and the received MIDI byte is saved in the
;RAM. Immediately afterwards the DMX transmission is continued.

 


                $NOMOD51
                $INCLUDE (89s52.mcu)


                TEMP    DATA    127


                ORG 0
            
                SJMP Start

                ORG 002BH

Start:          MOV AUXR,#00011001B     ;AT89S52 specific status byte

                MOV SCON,#01010000B     ;set UART to Mode 1 (1+8+1 bits)

                ORL TMOD,#00100000B     ;set Timer 1 (Mode 2)
                MOV TH1,#254            ;31250 Bds at 24.000MHz
                MOV TL1,#254            ;= MIDI baud rate
                SETB TR1                ;start Timer 1

                ANL T2CON,#11110000B    ;set Timer 2 (16bit auto-reload)
                ORL T2CON,#00010000B    ;Timer 2 for transmit clock
                MOV TH2,#255            ;initialize
                MOV TL2,#253
                MOV RCAP2H,#255         ;250000 Bds at 24.000MHz
                MOV RCAP2L,#253         ;= DMX baud rate
                SETB TR2                ;start Timer 2

                MOV R0,#128             ;Start address of DMX-bytes to
                                        ;be sent.
                MOV R1,#32              ;Start address of received MIDI-
                                        ;bytes.
                LCALL MIDI_receive      ;Save MIDI-byte, if arrived.

                CLR TXD                 ;fabrication of BREAK
                MOV TEMP,#87
                DJNZ TEMP,$             ;BREAK >= 88µsec

                SETB TXD                ;fabrication of MARK
                MOV TEMP,#4
                DJNZ TEMP,$             ;MARK >= 8µsec

                LCALL MIDI_receive      ;Save MIDI-byte, if arrived.

                MOV SBUF,#0             ;send START-byte

                JNB TI,$                ;byte sent?
                CLR TI                  ;prepare UART for next sending
                MOV TEMP,#4
                DJNZ TEMP,$             ;2 stop bits >= 8µsec

                LCALL MIDI_receive      ;Save MIDI-byte, if arrived.

DMX_send:       MOV SBUF,@R0            ;send a DMX-byte waiting in RAM

                INC R0                  ;prepare address of next DMX-byte
                JNB TI,$                ;byte sent?
                CLR TI                  ;prepare UART for next sending
                MOV TEMP,#3
                DJNZ TEMP,$             ;2 stop bits >= 8µsec

                LCALL MIDI_receive      ;Save MIDI-byte, if arrived.

                CJNE R0,#0,DMX_send     ;all DMX-bytes sent?

                SJMP $                  ;code snippet ends here



MIDI_receive:   JNB RI,End_call         ;MIDI_byte received?
                CLR RI                  ;prepare UART for next receiving
                MOV @R1,SBUF            ;store MIDI-byte in RAM
                INC R1                  ;prepare address of next MIDI-byte
End_call:       RET



                END


Kai

List of 53 messages in thread
TopicAuthorDate
Is possible? AT89S52 with dual serial baud rate            01/01/70 00:00      
   yes...            01/01/70 00:00      
   Use Timer 2...            01/01/70 00:00      
      Can I have both at same time?            01/01/70 00:00      
         you can't have different baudrates...            01/01/70 00:00      
         YES            01/01/70 00:00      
         No, unless...            01/01/70 00:00      
            what registers?            01/01/70 00:00      
               Split-speed common in older times            01/01/70 00:00      
               Timer 2 registers of AT89S52            01/01/70 00:00      
   Where can I read...            01/01/70 00:00      
      Well, in the datasheet!            01/01/70 00:00      
      Tutorials; FAQs            01/01/70 00:00      
   You have two UART's ... Does that give you any ideas?            01/01/70 00:00      
   Timer2 baudrate            01/01/70 00:00      
      unconfuse yourself            01/01/70 00:00      
      What's wrong with page 15 of datasheet?            01/01/70 00:00      
      Trying this...            01/01/70 00:00      
         Have a look at this code example...            01/01/70 00:00      
            This damn 52 think it is a 51 !!!            01/01/70 00:00      
               counterfeit chip?            01/01/70 00:00      
   It is for a Midi to DMX project... new trouble            01/01/70 00:00      
      Alternatives            01/01/70 00:00      
         examples            01/01/70 00:00      
            Options            01/01/70 00:00      
   Found the crystal!            01/01/70 00:00      
      Let's see ... What is wanted here ...            01/01/70 00:00      
         He is already using two timers            01/01/70 00:00      
            Independent UARTs            01/01/70 00:00      
               Crystal seens OK - Could receive Midi.. "partially" send DMX            01/01/70 00:00      
                  Well done!            01/01/70 00:00      
                  Russel Bull... Can you please take a look in my code?            01/01/70 00:00      
                  I wouldn't use serial transmission interrupts            01/01/70 00:00      
                     Makes sense!            01/01/70 00:00      
                        Give this a try...            01/01/70 00:00      
                           Hard to find a place to test.            01/01/70 00:00      
                              Runtime of LCALL...            01/01/70 00:00      
                           stop bits            01/01/70 00:00      
                              TI flag is set at the begin of (first) stop bit!            01/01/70 00:00      
                                 TI/RI setting time            01/01/70 00:00      
                                    TI and RI details...            01/01/70 00:00      
   TI/RI question            01/01/70 00:00      
      what causes a serial int?            01/01/70 00:00      
      More things will happen...            01/01/70 00:00      
         If....            01/01/70 00:00      
            Yes            01/01/70 00:00      
   YEAAAAAAAAH! IT WORKED            01/01/70 00:00      
      Congrats!            01/01/70 00:00      
         Thanks really a lot!            01/01/70 00:00      
   A new challenge! The inverse way!            01/01/70 00:00      
      BREAK detection is lousy!            01/01/70 00:00      
         RB8            01/01/70 00:00      
            RB8 details...            01/01/70 00:00      

Back to Subject List