At 07:32 PM 1/19/98 +0100, you wrote: >Hello EveryOne, > >I've written a piece of code... But unfortualy it doen not work right... >The 16c84 communicates with 3 CD4094 IC's. (Serial to parrallel). The error >MUST be in the hef4094 routine, but i can't finft the error... Who can find >the problem? > >(-----Cut----) >SendOne > bsf DATA > call wait > bsf CLOCK > call wait > bcf DATA > nop > bcf CLOCK > return > >SendZero > bcf CLOCK > call wait > bsf CLOCK > call wait > bcf CLOCK > return > >hef4094 > movwf txbyte > movlw 0x07 > movwf bitcount >Sendbit > btfss txbyte, bitcount ; Skip next line if bit is set. > call SendZero ; Sends a 0 > call SendOne ; Sends a 1 > decfsz bitcount,1 ; Decrement bitcount, SKip if Zero > goto Sendbit > return > >(----Cut-----) > >main > movlw 0xFF > call hef4094 > movlw 0x00 > call hef4094 > movlw 0x00 > call hef4094 > goto main >end > >This piece of code should make 8 of the 24 bits high... But when I look at >the outputs of the CD4094 it isn't... >He problably sends one Bit to much or something... >Greetz, > Radboud Verberne. > Radbound, I believe your biggest problem is trying to use a variable to select the bit number. BTFSS needs a constant for the bit number so what it does is use the address (probably truncated to 3 bits) of the variable . Also, when you call SendZero, it returns and calls SendOne immediately. You might try: Sendbit rrf txbyte,f ;rotate LSB into carry bit btfss STATUS,C ;is it a 0 goto Zero ;yes, send a zero bit call SendOne ;no, send a one bit goto Nextbit ;go check bit counter Zero call SendZero ;go send a zero bit Nextbit decfsz bitcount,f are we done? goto Sendbit return I haven't tested this code or optimized it but it should work. Hope this helps! Greg Maki