Hi PIC people, I have been attempting to interface a 16C84 to an LCD serial backpack as produced by Scott Edwards Electronics (www.seetron.com). I have tried many different bit-banging serial programs out there, none of which seem to work. I realise that the serial backpack needs inverted serial data - which requires swapping any bcf and bsf opcodes. However, does this include inverting the start and stop bits? 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. The PIC is using 4Mhz crystal in HS mode. The source below is for gpasm ( a GNU PIC assembler, but it will work in mpasm with some tweaks). Btw - I used a PIC disassembler to verify that the .hex file corresponds to the assembler listing! 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? Many thanks! Mark. ; 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