The more I learn the more complex my problems! I have written my first PIC serout routine and it doesn't work. It is suppose to send 5 bytes of data from an array at 9,600 baud inverted. It is a little complicated because of the mulititasking with other routines like servo and PWM. This routine begins by testing an input line to see if the BS2 is ready to receive data. If the "handshake" line is high it is suppose to load bytes from the array and send them. When the byte counter =0 the routine is suppose to jump to the serin routine to receive data from the BS2. If the "handshake" is low the routine starts a pulse measurement routine. If the pulse measure routine has started, it will finish prior to allowing serout, even if the "handshake" is high. The program looked pretty good on the simulator, except that I don't know how to simulate a serial transmission. I am using a BS2 to initialize the "handshake" and receive the serial data and display it on a LCD. When I run the program, the serout data looks like a gasoline display pumping 1000 gallon a second. All I see are random numbers (at least numbers that don't make any sense) and it never jumps to the serin routine. The numbers are rapidly changing and never stabylize. The first 2 bytes SENT are the result of the pulse measurement, the second two bytes are 20 msec accumulated counts, and the last is a 22 minute counter. The "dummy" byte provides the starting point of the array. If I disable the serout routine and point the PCL to the serin routine, the serin routine (sent via BS2) works perfect. Maybe my serout routine is flawed? Or is it the way I read the array to send the bytes? I wrote the code to be inverted, did I do it right? What does the BS2 need to receive these bytes. The BS2 serin routine looks like this. SERIN 13, 16468, 300, TM_OUT, [PULSIN_L, PULSEIN_H, MSEC_COUNT_L, MSEC_COUNT_H, _22MIN_COUNT] I have included a snip of the program, its pretty long though. I know you guys like a little detail though. SERIAL MOVF SSTATE,W ; MOVWF PCL ; dispatch to current state TEST: BTFSC _HANDSHAKE ; CHECK FOR SERIAL PSEUDO HANDSHAKE GOTO LOADSEROUT ; PIN=1 INITIATE SEROUT COMM MOVLW ZERO_1 MOVWF SSTATE GOTO W9 ZERO_1: ;PULSE MEAUREMENT ROUTINE 25uS RESOLUTION-SET FOR OVERFLOW AT 328 MSEC------------ ; ; REAL SERIAL ROUTINES-------------------------------------------------------- ; SEND 5 BYTES INVERTED 9600 BITTIME = 4 LOADSEROUT: MOVLW 6 ;LOAD COUNTER MOVLW SINDEX ;LOAD SINDEX WITH 6 MOVLW SEL_OUTBYTE ;SELECT BYTE TO SEND MOVWF SSTATE GOTO W10 SEL_OUTBYTE DECFSZ SINDEX,F ;START AT OFFSET=5 COUNTER INIT W/6 GOTO $+2 GOTO CHANGEMODE ;SINDEX=0 LOAD SERIN ROUTINE MOVLW DUMMY ;DUMMY POINT TO INITIALIZE COUNTER ADDWF SINDEX,W ;MOVE TO OFFSET MOVWF FSR ; MOVF INDF,W MOVWF OUTBYTE MOVLW SEROUT MOVWF SEROUT BTFSS _HANDSHAKE GOTO IDL9 ; FALSE START RECEIVER NOT READY WAIT AND RETURN MOVF OUTBYTE,W ; MOVE OUTBYTE INTO SSHIFT MOVWF SSHIFT MOVLW BITTIME ;SET BAUD TIME MOVWF STIME MOVLW SENDSTART ; MOVWF SSTATE ;SEND PGM TO SENDSTART GOTO W13 SENDSTART BSF _SEROUT ;SET START BIT DECFSZ STIME,F ;WAIT FOR BAUD DELAY GOTO W5 ;WAS W5 (+3) MOVLW SEND_BIT ; MOVWF SSTATE ;SEND PGM TO SEND_BIT MOVLW 8 ;SEND 8 BITS MOVWF SCOUNT ;BIT COUNTER ; MOVLW BITTIME MOVWF STIME NOP RETURN SEND_BIT RLF SSHIFT,F ; SHIFT PULSE BITS RIGHT BSF _SEROUT ; INITIALIZE BTFSC STATUS,C ; TEST CARRY IF 0 SEND 1, IF 1 SEND 0 BCF _SEROUT ; REMEMBR INVERSE DECFSZ STIME,F ; WAIT FOR BAUD DELAY GOTO W8 ; DECFSZ SCOUNT,F ; NEXT BIT GOTO RELOADTIME MOVLW SENDSTOP MOVWF SSTATE ; SEND PGM TO SENDSTOP MOVLW BITTIME MOVWF STIME RETURN ; SENDSTOP BCF _SEROUT ;SEND STOP BIT DECFSZ STIME,F ;WAIT FOR BAUD DELAY GOTO W5 ; MOVLW SEL_OUTBYTE ;GET A NEW BYTE TO SEND OR GO SERIN MOVWF SSTATE GOTO W8 CHANGEMODE MOVLW LOADLOOP ;GOTO SERIN MOVWF SSTATE ; CLRF SINDEX ;INITIALIZE SINDEX GOTO W12 RELOADTIME MOVLW BITTIME MOVWF STIME RETURN ; ; ;SERIAL IN ROUTINE--------------------------------------------------------- ; LOADLOOP ; Waste cycles to make up 19 cycles including call and return. W4 NOP W5 NOP W6 NOP W7 NOP W8 NOP W9 NOP W10 NOP W11 NOP W12 NOP W13 RETURN ; Select Idle state and waste cycles to make up 19 cycles ; including call and return. IDL4 NOP IDL5 NOP IDL6 NOP IDL7 NOP IDL8 NOP IDL9 NOP IDL10 NOP IDL11 MOVLW TEST ;FALSE START MOVE PGM COUNTER TO TEST MOVWF SSTATE ; select IDLE state RETURN END