I am having serial port communications problems. Below is the simple code in the DS89C450 MCU that I am trying to get to work properly. It is a simple routine to receive data via the serial port at 38400baud. I am trying to receive 65536 bytes. It allways drops some of the data like it is falling behind the serial stream. Most the time the 1st 1000 bytes seem fine then one is missed and the data in memory is short a byte. This happens many times after the 1st 1k bytes. I am using Visual C++6.0 as my pc software to send data from the pc to the DS89C450. I did find that I had to buffer the ALE line to the latches for more reliability. Do I need to buffer the WR & RD also or add pull-ups on other pins? According to the data sheet the Address/Data lines dont need pull-ups if thats all there used for. My MCU circuit is very simple and uses 1-DS89C450MNL, 2-74F573 latches for address, 1-IS62C1024AL-35 Ram, 1-74HCT32 used as a buffer for ALE, 1-MAX233CPP Rs232. I have A16 tied low on Ram chip. If I insert a 1ms delay between characters sent by the pc, it works fine. But that defeats the speed-up in communications. I can verify that data is missing by dumping the memory contents with another routine in the micro to send the last 256 bytes of memory. Out of 65536 bytes there is 7 bytes missing.
This is the code inside the DS89C450 MCU running at 29.491mhz
pcon equ 87h ;address of PCON register scon1 equ 0c0h ;address of SCON1 register sbuf1 equ 0c1h ;address of SBUF1 register wdcon equ 0d8h ;address of WDCON register ckcon equ 8eh ;location of clock control org 0000h ljmp start
org 100h ;allways start ROM program at 0100h start: mov scon,#50h ;set serial port 0 to mode 1 with rec enabled mov tmod,#20h ;set timer 1 as auto-reload 8-bit timer mov th1,#0feh ;baud rate equals 38400b at 29.491mhz w/smod=0 mov ie,#80h ;do not enable serial interupt mov tcon,#40h ;start timer 1 setb ea ;global enable interrupts setb p3.6 ;set pull-up on WR setb p3.7 ;set pull-up on RD clr ri ;ensure that receive interupt flag is cleared clr ti
loop: jnb ri,loop mov a,sbuf clr ri cjne a,#01h,chka ;01 = get job data from pc ljmp getst chka: ljmp loop
; ; ***** Get track / sector data from PC ***** ; getst: clr p1.0 ;set RomA16 false clr p1.4 ;set RamA16 true setb p1.2 ;disable ROM clr p1.3 ;enable RAM mov r1,#00h mov dptr,#0000h getst1: mov r2,#00h getst2: jnb ri,getst1 ;wait for char from pc mov a,sbuf clr ri movx @dptr,a inc dptr djnz r2,getst2 djnz r1,getst1 ;get 65536d bytes ff x ff ljmp loop