89C52 UART WITH 24MHz SETTING REQUIRED

Discussion in 'Programmer's Corner' started by saha, Apr 29, 2007.

  1. saha

    Thread Starter Well-Known Member

    Jun 1, 2006
    53
    0
    Hi all,

    Can any one tell me how to use the UART for various baud rates for 89C52 Which runs with clock of 24MHz. I've googled but couldn't get it. please help me.

    regards,
    saha
     
  2. beenthere

    Retired Moderator

    Apr 20, 2004
    15,815
    282
  3. saha

    Thread Starter Well-Known Member

    Jun 1, 2006
    53
    0
    Hi all,
    Thanks a lot, i tried a lot and got a solution. As a simple logic if we configure a 89C52 to run at 300bps, by replacing the 12MHz with 24MHz we can get the serial transmission to be double the speed that is 600bps. With this crude logic i checked by prgramming and replacing it worked. hence just giving the reload values. hope will be of use to some one.

    BAUD RATEs a,b,c,d

    (a) - FOR 89C52 CLK 12MHz without doubling baud rate

    (b) - FOR 89C52 CLK 12MHz with doubling baud rate .
    MOV PCON,#080h

    (c) - FOR 89C52 CLK 24MHz without doubling baud rate

    (d) - FOR 89C52 CLK 24MHz with doubling baud rate .
    MOV PCON,#080h

    (e) TH1 -AUTO RELOAD VALUE


    12MHz 24MHz TH1

    (a) (b) (c) (d) (e)
    ; 300 600 600 1200 98h
    ; 1200 2400 2400 4800 E8h
    ; 2400 4800 4800 9600 F4h
    ; 4800 9600 9600 19200 FAh
    ; 9600 19200 19200 38400 FDh


    of course 89c52 are becoming obsolete but there are countless systems which run on these processors and undoubtedly the designers are CRAMMING the hardware logic in it.

    regards,
    saha
     
  4. Arm_n_Legs

    Active Member

    Mar 7, 2007
    183
    10
    Example: 9600 bps on 24 MHz

    9600 x 32 = 307200

    Interval between overflow = 1/307200 = 3.255 us

    Timer run rate = 1(24000000/12) = 0.5 us

    Count = 3.255/0.5 = 6 (there will be baud rate error)

    (TL1) = 255 - 6 = 249 (F9h)

    To avoid baud rate error, use 22.1184 MHz crystal.

    MOV TMOD,#20H
    MOV SCON,#50H
    MOV TH1,#0F9H
    SETB TR1
     
Loading...