Serial transfer problem

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View


I am using a DS89C440 flash micro running at 29.491Mhz with 64k of external
RAM and no external ROM.
I am running my serial port using timer-1 for baud rate generator at
19200baud.
My source computer is a P4-3Ghz running winxp-pro and my program for sending
data to the micro is Visual C++ 6.0
For some reason I dont under stand, not all the data I send to the micro
gets there.
My serial receive code for the micro is below:
;
; ***** Get job data from PC *****
;
  getpc: mov   dptr,#1000h            ;set dptr to data area
 getpc1: jnb   ri,getpc1
          mov   a,sbuf                 ;get char from port
          clr   ri
          movx  @dptr,a                ;save data to memory
          inc   dptr
          mov   a,dph
          cjne  a,#20h,getpc1          ;receive 8319 bytes
          mov   a,dpl
          cjne  a,#7fh,getpc1
          ljmp  loop                     ;top of program

Any ideas???



Re: Serial transfer problem



Quoted text here. Click to load it

How many bytes are you losing? a random amount? do you expect to receive
207f bytes?



Re: Serial transfer problem


I am allways expecting to receive 207Fh bytes because that is how many are
allways transmitted by the PC program.
The number of bytes missing seems random. Sometimes I only miss a few bytes
and other times I am missing quite a few.


Quoted text here. Click to load it



Re: Serial transfer problem



Hi Ed,

Quoted text here. Click to load it


Two thoughts.

    1    Are you SURE the PC is sending 3819 bytes each time?  Prove with
another PC running HyperTerminal.

    2    Do you have any interrupts running on your micro?

  Jay


Re: Serial transfer problem


I am sure of the number of bytes transferred and tested with 2nd pc using
hyperterm.
I am using no interrupts on the micro, my serial uses polling only.
I dont see how making the serial routing interrupt driven would help.
I think it would increase the possibility of missing bytes more possible due
to the extra instructions.
I am doing nothing else while receiving data from the pc.


Quoted text here. Click to load it



Re: Serial transfer problem



Quoted text here. Click to load it

Make the code an interrupt service routine......

RXint:

         mov   a,sbuf                 ;get char from port
          movx  @dptr,a                ;save data to memory
          inc   dptr
          mov   a,dph
          cjne  a,#20h,getpc1          ;receive 8319 bytes
          mov   a,dpl
          cjne  a,#7fh,getpc1

          set complete flag here
            disable rx interrupts

get1pc    rti



Site Timeline