Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Presented by:-Gaurav SaraswatAssociate Designing Engineer at Tevatron Technology
Basics of serial CommunicationParallel: expensive - short distance – fast – no modulationSerial :cheaper– long (two differ...
Basics of serial communication
Packaging DataStart and stop bitsIn asynchronous transmissionWhen there is no transfer the signal is highTransmission beg...
RS232 Standard1 DCD2 RD3 TD4 DTR5 GND6 DSR7 RTS8 CTS9 RI Create in 1960 and updated in 1969 Logic 1 : -3 to -25 volt Lo...
MAX232 or MAX233
SBUF registerMOV SBUF,#’D’ ;load SBUF=44H, ASCII for ‘D’MOV SBUF,A ;copy accumulator into SBUFMOV A,SBUF ;copy SBUF into a...
Serial control (SCON) RegisterSM2 : used for multi processor communicationREN : receive enable (by software enable/disable...
Mode of operation Mode 0 : Serial data enters and exits through RxD TxD outputs the shift clock. 8 bits are transmitte...
Timing of send in mode 0One machine cycleoscillator cycleRXD (data)TXD (clock pulse)MOV SCON,#0001xxxxBWait: JNB RI,WAITCL...
Mode of operation Mode 1 Ten bits are transmitted (through TxD) or received (through RxD)(A start bit (0), 8 data bits (...
TimermodesGATE C/T M1 M0 GATE C/T M1 M0Timer 1 Timer 0(MSB) (LSB)
Programming for sending data( in mode 1 )4. SETB TR15. MOV SBUF, DATA6. WAIT: JNB TI,WAIT7. CLR TIBAUD RATE VALUE IN TH VA...
Programming for sending data( in mode 1 )MOV TMOD,#20H ;TIMER 1 MODE 2MOV TH1,#-3 ;9600 BAUDMOV SCON,#50H ;REN enableSETB ...
Programming for recieving data( in mode 1 )MOV TMOD,#20H ;TIMER 1 MODE 2MOV TH1,#-3 ;9600 BAUDMOV SCON,#50H ;REN enableSET...
Mode of operation Mode 2 : Eleven bits are transmitted (through TxD), received (through RxD) A start bit (0) 8 data bi...
Mode of operation
What is SMOD Bit 7 of PCON register If SMOD=1 double baud rate PCON is not bit addressable How to set SMODMov a, pconS...
Power control register
Power control A standard for applications where power consumptionis critical two power reducing modes Idle Power down
Idle mode An instruction that sets PCON.0 causes Idle mode Last instruction executed before going into the Idle mode th...
Power-Down Mode An instruction that sets PCON.1 causes power dowm mode Last instruction executed before going into the p...
Power control exampleOrg 0000hLjmp mainOrg 0003hOrl pcon,#02h ;power down modeRetiOrg 0030hMain:………………Orl pcon,#01h ;Idle ...
example
Sereial com. ppt
Sereial com. ppt
Upcoming SlideShare
Loading in …5
×

Sereial com. ppt

419 views

Published on

  • Be the first to comment

  • Be the first to like this

Sereial com. ppt

  1. 1. Presented by:-Gaurav SaraswatAssociate Designing Engineer at Tevatron Technology
  2. 2. Basics of serial CommunicationParallel: expensive - short distance – fast – no modulationSerial :cheaper– long (two different cities by modem)-slow
  3. 3. Basics of serial communication
  4. 4. Packaging DataStart and stop bitsIn asynchronous transmissionWhen there is no transfer the signal is highTransmission begins with a start (low) bitLSB firstFinally 1 stop bit (high)Data transfer rate (baud rate) is stated in bps
  5. 5. RS232 Standard1 DCD2 RD3 TD4 DTR5 GND6 DSR7 RTS8 CTS9 RI Create in 1960 and updated in 1969 Logic 1 : -3 to -25 volt Logic 0 : 3 to 25 volt To Connect TXD to RXD and RXD to TXD frompc to 8051 you must use max232 to convertsignal from TTL level to RS232 level The baud rate of the 8051 must matched thebaud rate of the pc PC standard baud rate (see hyper terminalconfiguration) 2400-4800-9600-14400-19200-28800-33600-57600
  6. 6. MAX232 or MAX233
  7. 7. SBUF registerMOV SBUF,#’D’ ;load SBUF=44H, ASCII for ‘D’MOV SBUF,A ;copy accumulator into SBUFMOV A,SBUF ;copy SBUF into accumulator
  8. 8. Serial control (SCON) RegisterSM2 : used for multi processor communicationREN : receive enable (by software enable/disable)TB8 : transmit bit8RB8 : receive bit 8TI : transmit interrupt flag set by HW after send , clear by SWRI : receive interrupt flag set by HW after received ,clear by SWSM0 RITIRB8TB8RENSM2SM17 6 5 4 3 2 1 0SM0 SM1 MODE operation transmit rate0 0 0 shift register fixed (xtal/12)0 1 1 8 bit UART variable (timer1)1 0 2 9 bit UART fixed (xtal/32 or xtal/64)1 1 3 9 bit UART variable (timer1)SM0 : mode specifierSM1 : mode specifier
  9. 9. Mode of operation Mode 0 : Serial data enters and exits through RxD TxD outputs the shift clock. 8 bits are transmitted/received(LSB first) The baud rate is fixed a 1/12 the oscillator frequency. Application Port expansion8051TXDRXD Shift registerclkdata
  10. 10. Timing of send in mode 0One machine cycleoscillator cycleRXD (data)TXD (clock pulse)MOV SCON,#0001xxxxBWait: JNB RI,WAITCLR RIMOV A,SBUFMOV SCON,#0001xxxxBWait: JNB TI,WAITCLR TIMOV SBUF,A
  11. 11. Mode of operation Mode 1 Ten bits are transmitted (through TxD) or received (through RxD)(A start bit (0), 8 data bits (LSB first), and a stop bit (1) ) On receive, the stop bit goes into RB8 in SCON the baud rate is determined by the Timer 1 overflow rate. Timer1 clock is 1/32 machine cycle (MC=1/12 XTAL)• Timer clock can be programmed as 1/16 of machine cycle• Transmission is initiated by any instruction that uses SBUF as adestination register.
  12. 12. TimermodesGATE C/T M1 M0 GATE C/T M1 M0Timer 1 Timer 0(MSB) (LSB)
  13. 13. Programming for sending data( in mode 1 )4. SETB TR15. MOV SBUF, DATA6. WAIT: JNB TI,WAIT7. CLR TIBAUD RATE VALUE IN TH VALUE IN HEX9600 -3 FD4800 -6 FA2400 -12 F41200 -24 E8XTAL=11.0592 MHzGATE C/T M1 M0 GATE C/T M1 M0Timer 1 Timer 0(MSB)(LSB)1. MOV TMOD,#20H2. MOV TH1,# baud rate3. MOV SCON,#50HSM0 RITIRB8TB8RENSM2SM1
  14. 14. Programming for sending data( in mode 1 )MOV TMOD,#20H ;TIMER 1 MODE 2MOV TH1,#-3 ;9600 BAUDMOV SCON,#50H ;REN enableSETB TR1 ;start timer1AGAIN: MOV SBUF, # “A”WAIT: JNB TI,WAITCLR TISJMP AGAINSerial example(1)
  15. 15. Programming for recieving data( in mode 1 )MOV TMOD,#20H ;TIMER 1 MODE 2MOV TH1,#-3 ;9600 BAUDMOV SCON,#50H ;REN enableSETB TR1 ;start timer1WAIT: JNB RI,WAITMOV A,SBUFCLR RISJMP WAITSerial example(2)
  16. 16. Mode of operation Mode 2 : Eleven bits are transmitted (through TxD), received (through RxD) A start bit (0) 8 data bits (LSB first) A programmable 9th data bit and a stop bit (1) On transmit, the 9th bit (TB8) can be assigned 0 or 1. On receive, the 9the data bit goes into RB8 in SCON. the 9th can be parity bit The baud rate is programmable to 1/32 or 1/64 the oscillator frequency inMode 2 by SMOD bit in PCON register Mode 3 Same as mode 2 But may have a variable baud rate generated from Timer 1.
  17. 17. Mode of operation
  18. 18. What is SMOD Bit 7 of PCON register If SMOD=1 double baud rate PCON is not bit addressable How to set SMODMov a, pconSetb acc.7Mov pcon,a
  19. 19. Power control register
  20. 20. Power control A standard for applications where power consumptionis critical two power reducing modes Idle Power down
  21. 21. Idle mode An instruction that sets PCON.0 causes Idle mode Last instruction executed before going into the Idle mode the internal CPU clock is gated off Interrupt, Timer, and Serial Port functions act normally. All of registers , ports and internal RAM maintain their data during Idle ALE and PSEN hold at logic high levels Any interrupt will cause PCON.0 to be cleared by HW (terminate Idle mode) then execute ISR with RETI return and execute next instruction after Idle instruction. RST signal clears the IDL bit directly
  22. 22. Power-Down Mode An instruction that sets PCON.1 causes power dowm mode Last instruction executed before going into the power downmode the on-chip oscillator is stopped. all functions are stopped,the contents of the on-chip RAMand Special Function Registers are maintained. The ALE and PSEN output are held low The reset that terminates Power Down
  23. 23. Power control exampleOrg 0000hLjmp mainOrg 0003hOrl pcon,#02h ;power down modeRetiOrg 0030hMain:………………Orl pcon,#01h ;Idle modeend
  24. 24. example

×