Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Serial Port Configuration for 89C2051

Someone please help me out with a script to setup the serial I/O for an 89c2051. I need 9600 baud with 8-N-1.


Comments

  • peretperet Member Posts: 69
    : Someone please help me out with a script to setup the serial I/O for an 89c2051. I need 9600 baud with 8-N-1.
    :
    :
    :

    Here's a snip from an actual 89C2051 program.

    ; set up timers and serial port
    ; 11.0592MHz clock - adjust constants for different rate
    reload equ -29 ; T0 reload for 1000us
    b96 equ -6
    b192 equ -3
    baud_rate equ b96
    ; baud rate formula:
    ; divisor = crystal/(192*baud rate) if SMOD=1
    ; else crystal/(384*baud rate) if SMOD=0
    ; reload values are -ve because counters count UP

    mov PCON,#10000000B ; SMOD=1, 2x baud rate
    mov TCON,#00000000B ; timer disable
    mov TMOD,#00100000B ; T0 mode 0, T1 mode 2
    mov TH0,#reload ; 1ms at 11.0592
    mov TH1,#baud_rate ; baud rate generator
    mov TCON,#01010001B ; turn on timers and IE0 edge
    mov SCON,#01010000B ; serial: mode 1, RX enable

    ; all set

Sign In or Register to comment.