Serial data problems

Discussion in 'Embedded Systems and Microcontrollers' started by bas, Apr 11, 2008.

  1. bas

    Thread Starter New Member

    Apr 11, 2008

    My requirement is also similar to the one stated here. I also need to get parallel data into serial port for which i used AT89C2051. But the circuit is not working. Could i please know if there are any errors in my program itself which is inhibiting the implementation of the circuit. The code is assembling and simulating fine

    org 0000h
    mov tmod,#20h
    mov th1,#-6
    mov scon, #40h
    setb tr1
    mov p1,#0ffh
    again: jb p3.2, l1
    sjmp again
    l1: mov a, p1
    mov sbuf,a
    here: jnb ti,here
    clr ti

    sjmp again

    Our requirement is for the AT89C2051 to take in data in parallel and send it out serially, using serial transmission. Hence the required statements are included to set baud rate at 9600 bps and a crystal oscillator of 11.0592MHz is used. Pin 6, ie P3.2 is connected to StD pin of DTMF decoder. and StD goes high when an output is latched in the decoder. So our program is written to take data from port 1 each time StD goes high. I want to know if any practical considerations have been overlooked in this program which is causing it to not run properly, because it is assembling and simulating fine. Also, do we need to write a code for it to access each bit of data separately from port 1 or what we have written is fine? Please help
  2. SgtWookie


    Jul 17, 2007
    Although your request is similar to the original thread, it's really a very different question. You're generally much better off to start a new thread than to "tack on" to an existing one, as that helps a great deal to keep the threads from being confusing.

    I'm not familiar with that particular version of Assembler (the mneumonics), however I've taken the liberty to re-format your source code for readability's sake, and surrounded it with CODE /CODE brackets to preserve the formatting.

    When I'm writing Assembler, I comment every line. That way, it's much easier to return to it later and understand what the intended purpose of a particular line of code is.
    I also got in the habit of placing branch labels on their own line rather than combining them with other statements. Your version of assembler may require alignment of branches on halfword or fullword boundaries. Using an EQU * as an address reference can be risky if halfword/fullword alignment is required.

    Code ( (Unknown Language)):
    1.          org      0000h
    2.          mov      tmod,#20h
    3.          mov      th1,#-6
    4.          mov      scon,#40h
    5.          setb     tr1
    6.          mov      p1,#0ffh
    7. again:                      
    8.          jb       p3.2, l1
    9.          sjmp     again
    10. l1:
    11.          mov      a, p1
    12.          mov      sbuf,a
    13. here:
    14.          jnb      ti,here
    15.          clr      ti
    16.          sjmp     again
    17.          end
  3. bas

    Thread Starter New Member

    Apr 11, 2008
    Thank you, that has certainly enhanced the readability of the code. But that itself will not make any difference to the code itself right? Also yes, i also realized that i could have looped back in the same statement and i did it too. But even with it, our circuit is not workin. Any pointers as to why it might not be working. We might be over-looking some really simple step or point.