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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/11/05 14:02
Read: times


 
#89457 - Sorry, since the program is very large..
Responding to: ???'s previous message
Sorry, since the program is very large... so just copy the part i think is related to the serial communication.

First call INIT_SERIAL:, then SEND_OUT: and the serial interrupt will loop to send 8 bytes of data.

Here is part of the code.

SEND_OUT:
call INIT_SERIAL
setb EA
mov r0,#00h
mov r1,#BUFFER

mov BUFFER,#0ffh
mov BUFFER+1,#0ffh
mov BUFFER+2,#0ffh
mov BUFFER+3,#0ffh
mov BUFFER+4,#0ffh
mov BUFFER+5,#0ffh
mov BUFFER+6,#0ffh
mov BUFFER+7,#0ffh

mov sbuf,@r1

LOOP: cjne r0,#07h,LOOP
clr EA
clr tr1
clr es
ret

INIT_SERIAL:

mov psw,#00h
mov tmod,#00100110b ;counter0 mode2
mov th0,#(256-COUNT)
mov tl0,#(256-COUNT)

mov th1,#0fdh
mov tl1,#0fdh ;TH1=TL1 = 256 - (freq / (32 * 12 * BAUD))

mov pcon,#00h

mov scon,#50h ;8-bit UART mode1 (Serial Mode 1 Set by Timer 1)

setb tr1 ;run timer1
setb es
clr tf0 ;clear interrupt flat
setb tr0 ;enable timer0
setb et0 ;enable timer0 interrupt

ret

;Serial interrupt routine
SERIAL_INT:
push acc
push psw
push 07h
INT_SERIAL: jnb ri,CHECK_TI ;If the RI flag is not set, we jump to check TI
mov a,sbuf ;If we got to this line, it is because the RI bit *was* set

clr ri ;Clear
jmp EXIT_INT
CHECK_TI: jnb ti,EXIT_INT ;If the TI flag is not set, we jump to the exit point
clr ti ;Clear the TI bit before we send another character
inc r1
mov a,@r1 ;r1 stores the address of ascill number
mov sbuf,a
inc r0
ret

List of 24 messages in thread
TopicAuthorDate
About Serial Communication!!!!!Help            01/01/70 00:00      
   insufficient            01/01/70 00:00      
      Sorry, the crystal is 11.0592MHz            01/01/70 00:00      
   It's a miracle            01/01/70 00:00      
      amazing            01/01/70 00:00      
         Sorry, since the program is very large..            01/01/70 00:00      
            Large program            01/01/70 00:00      
            Result            01/01/70 00:00      
               do you believe            01/01/70 00:00      
                  MAX232C            01/01/70 00:00      
               19200???            01/01/70 00:00      
                  PCON vs 6 clock            01/01/70 00:00      
                  P89C51RD2 6 clocks per machine cycle            01/01/70 00:00      
                     DESCRIPTION            01/01/70 00:00      
            Here we go again            01/01/70 00:00      
         Re:amazing            01/01/70 00:00      
   H or not            01/01/70 00:00      
      The chip is P89C51RD2            01/01/70 00:00      
         insufficient            01/01/70 00:00      
            I am not sure about that...            01/01/70 00:00      
               the 'H' is important            01/01/70 00:00      
                  is P89C51RD2HBP            01/01/70 00:00      
                     Solved            01/01/70 00:00      
   0xFF ???            01/01/70 00:00      

Back to Subject List