>I have been attempting to interface a 16C84 to an LCD serial backpack as >produced by Scott Edwards Electronics (www.seetron.com). > >The following is the simplest program I found that was posted here recently. I >have a scope on Pin 18 observing the output. There data is generated, but then >it suddenly goes dead (after about 2 seconds) - no more output is generated. I >generate a snapshot on the scope, and it shows the output as high for approx >1.4mS and low very briefly for 100uS. There are 8 bits output, but why are the >high and low times so different? According to the source, bit time is 104uS. > > >So my questions are: >1) Why does this program suddenly stop geneating output? >2) Does anyone have code to interface a PIC to a serial-LCD backpack? Hi there, Mark. Two questions: what radix is the assembler using? The dcimal point that was in front of the ".10" means 10 decimal. Check to see what your assembler expects. what is 'temp dt 0' ? Is that your assembler's way of reserving a RAM byte? Try equating temp to a specific RAM location. I have had problems with this routine on some funky UARTs. The problem appears to stem from the delays in calling TXBYTE and returning - some UARTs don't appear to resynchronize every byte. My fix has been to increase the number of stop bits by changing the ".10" mentioned above to ".15" (or 0x0F) - that has fixed any problems that **I** had. The routine works well - it lives in at least half a dozen projects. dwayne > >; test txbyte routine >; Mark Crosbie 9/9/98 >; Sends the letter A to the serial LCD on pin 18 (RA1) >; at 9600, 8N1. Assumes 4Mhz Xtal >; > > include p16c84.inc > processor 16c84 > > __CONFIG _CP_OFF & _WDT_OFF & _XT_OSC & _PWRTE_ON > >#define serport PORTA >#define dout 1 > > org 0 > > bsf STATUS, RP0 > bcf TRISA, dout > bcf STATUS, RP0 >loop: > movlw 170 ; alternating 1 and 0 pattern > call txbyte > goto loop >temp dt 0 > >;TXBYTE: send 1 byte @ 9600 baud: 1 RAM, 15 (16) ROM, 1043 cycles >;enters with data in w, exits with w trashed. >;Copyright (C) 1995 Dwayne Reid. May be freely used so long as this >;copyright notice is retained. > >txbyte ; send byte in W at 9600 baud (4MHz osc), 8N1 > movwf temp > movlw 10 ; 8 data + 1 start + 1 stop (inc for more stop bits) > clrc ; start bit > >txloop ; bit time = 104.167 uSec > skpnc > bsf serport,dout ; output bit = carry > skpc > bcf serport,dout > >dloop ; 95 clk cycle delay > goto $+1 ; 2-cycle NOP in 1 instruction! > addlw b'00010000' ; increment upper nibble > skpc ; delay = 6n -1 (1 less when falls thru) > goto dloop ; loop sixteen times > addlw -1 ; dec w, valid z, c=1 if w=0 after decrement > rrf temp,F ; carry will be set - shifted in as stop bit > skpz > goto txloop ; txloop is 104 clk cycles > return > >-- >Mark Crosbie http://www.best.com/~mcrosbie >Hewlett-Packard MS 47 LA mcrosbie@cup.hp.com >19447 Pruneridge Avenue (408) 447-2308 >Cupertino, CA 95014 (408) 447-6766 FAX Dwayne Reid Trinity Electronics Systems Ltd Edmonton, AB, CANADA (403) 489-3199 voice (403) 487-6397 fax