This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

C515C serial port initialization

Would someone be able to tell me how to initialize the serial port on the C515C so that when I send a printf statement I'll be able to read it on HyperTerminal.

It could be that I have not set up the baud rate, stop bit, and flow control on the HyperTerminal so any comments on this would be appreciated

  • You'll need to initialize the timer to generate the correct baud rate. You also need to decide if you will use interrupts. Refer to the 8051 manual for the former. You can poll on the RI
    or TI flags to do output w/o interrupts.
    Search the archives of Usenet comp.arch.embedded or go to http://www.8051.com
    for sample code.

  • Make sure that the oscillator frequency you have allows the baud rate you want. For example, 9600 baud is not possible with a 12MHz using timer 1.

    See http://www.keil.com/c51/baudrate.asp for baudrate reload values for Timer 1.

    Jon

  • Try that:
    **********************************************
    ;* Using 10 Bit Baudrate Generator *
    ;* Oscillator frequency = 10.0 MHz *
    ;* Set Baudrate to 9600 Baud *
    ;*********************************************
    BD BIT 0DFH
    SRELL DATA 0AAh
    SRELH DATA 0BAh
    InitSerial: SETB BD ; Baudrate Generator
    MOV SRELL,#0BFH ; (for 10MHz)
    MOV SRELH,#00000011B
    ORL PCON,#10000000B ; SMOD = 1
    MOV SCON,#01011010B ; Init Serial Interface


    regards
    Stefan