Serie

Páginas: 5 (1038 palabras) Publicado: 4 de febrero de 2014
Comunicación Serie

0

1

2

3

4

5

6

7

0

1

2

3

4

5

6

7

Microcontroladores - 3

1

Comunicación Asíncrona
Bit de Comienzo
(Start Bit)

n Bits de Datos

Bit de Fin
(Stop Bit)

Bit de Paridad
(Par o Impar)
Microcontroladores - 3

2

1

Comunicación serie en 8051
•TxD pata 11 del 8051 (P3.1)
p
(
)
•RxD pata 10 del 8051 (P3.0)•SCON
•SBUF
•F
Fuente de la velocidad de comunicación
t d l
l id d d
i


Microcontroladores - 3

3

SCON
Bit

Name

Dir

Explanation of Function
p

7

SM0

9Fh

Serial port mode bit 0

6

SM1

9Eh

Serial port mode bit 1.

5

SM2

9Dh

Mutliprocessor Communications Enable

4

REN

9Ch

Receiver Enable. This bit must be set in order toreceive
characters.

3

TB8

9Bh

Transmit bit 8. The 9th bit to transmit in mode 2 and 3
8
3.

2

RB8

9Ah

Receive bit 8. The 9th bit received in mode 2 and 3.

1

TI

99h

Transmit Flag. Set when a byte has been completely transmitted.

0

RI

98h

Receive Flag. Set when a byte has been completely
received.
Microcontroladores - 3

4

2

SM0 y SM1
SM0 SM1Modo

Explicación

Velocidad de la
Comunicación

0

0

0

8-bit Shift Register

Oscilador / 12

0

1

1

8-bit UART

Fijada por Timer 1

1

0

2

9-bit UART

Oscilador / 32

1

1

3

9-bit UART

Fijada por Timer 1

SM2 = Comunicación Multiprocesador
Microcontroladores - 3

5

SM2
SM2 = Comunicación Multiprocesador
Si SM2 = 1
RI = 1 sólo si el9°bit esta en 1

Microcontroladores - 3

6

3

Comunicación Multiprocesador
• El maestro envía la dirección del
dispositivo a di l
di
iti
dialogar con el 9º bit en 1
l
1.
• Todos se interrumpen y verifican si es
para ellos.
• El seleccionado cambia de modo de
trabajo junto con el maestro
maestro.
• Al terminar el diálogo ambos vuelven al
modo de 9º bit.
Microcontroladores - 37

Programando la Comunicación
serie

Si PCON.7 = 0
Si PCON.7 = 1

TH1 = 256 - ((Cristal / 384) / Vel)
TH1 = 256 - ((Cristal / 192) / Vel)

Microcontroladores - 3

8

4

Ejemplo: 19.200 b/s
TH1 = 256 - ((Cristal / 384) / Vel)
TH1 = 256 - ((11059000 / 384) / 19200 )
TH1 = 256 - ((28,799) / 19200)
TH1 = 256 - 1.5 = 254.5
Con PCON.7 = 1
TH1 = 256 - ((Cristal / 192) / Vel)((
)
)
TH1 = 256 - ((11059000 / 192) / 19200)
TH1 = 256 - ((57699) / 19200)
TH1 = 256 - 3 = 253

Microcontroladores - 3

9

Comunicación serie – Uso del
Timer 1
MOV
ORL
MOV
MOV
SETB
SETB
SETB
JMP

SCON, #50h
,
TMOD, #20h
TH1, #0FDh
TL1, #0FDh
ES
EA
TR1
$

;
;
;
;
;
;
;

uart en modo 1 (8 bit), REN=1
Timer 1 en modo 2
9600 Bit/s a 11.059MHz
9600 Bit/s a11.059MHz
Habilitar interrupción serie
Habilitar interrupción global
Arrancar Timer 1

Microcontroladores - 3

10

5

Comunicación serie – Uso del
Timer 2
MOV
ANL
ORL
MOV
MOV
MOV
MOV
SETB
SETB
SETB
JMP

SCON,#50h
; uart en modo 1 (8 bit), REN=1
T2CON,#0F0h ; EXEN2=0; TR2=0; C/T2#=0; CP/RL2#=0;
T2CON,#30h
T2CON #30h ; RCLK = 1 TCLK 1
1; TCLK=1;
TH2,#0FFh
; valorinicial
TL2,#0FDh
; valor inicial
RCAP2H,#0FFh ; recarga, 115200 Bit/s at 11.059MHz
RCAP2L,#0FDh ; recarga, 115200 Bit/s at 11.059MHz
ES
; Habilitar Interrupción serie
EA
; Habilitar Interrupción global
TR2
; ArrancarTimer 2
$
; Lazo sin fin

Microcontroladores - 3

11

Transmitiendo serie
• CLR
MOV
• JNB

TI
; Garantizar TI = 0
SBUF,# A
SBUF #’A’ ; Transmitir ‘A’
A
TI,$
;Esperar que T1 se setee

Microcontroladores - 3

12

6

Leyendo el puerto serie
JNB

RI,$

; Esperamos a que llegue un símbolo

SETB
MOV
CLR
CJNE
CLR

LED
ED
A,SBUF
RI
// Se preapara para un nuevo datos
A,#'A', LEE_SERIE
LED

SJMP

LEE_SERIE

Microcontroladores - 3

13

Rutina de interrupción serie
INT_SERIAL:

JNB RI,CHECK_TI
,
MOV A,SBUF
CLR RI...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Lo Que No Seria
  • Series
  • SERIES
  • series
  • Series
  • Serie
  • Series
  • Serie

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS