Serial data problems

Thread Starter

bas

Joined Apr 11, 2008
3
Hello

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
end

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
 

SgtWookie

Joined Jul 17, 2007
22,230
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.

Rich (BB code):
         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
         end
 

Thread Starter

bas

Joined Apr 11, 2008
3
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.
 
Top