Hello , I need to send one word with the serial port from the PIC16F877 = on a bus . I made a program that reads in the state of a switch . When = the switch is "one"(5V) he must send the word , when it's 'zero' he = sends nothing .=20 My program must be seriously wrong because i get nothing out on my = serial port .(I have always 5 V) Maybe i must make use of interrupts ?? = I dont know . This is my program : list p=3D16f877 #include __CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _HS_OSC & = _WRT_ENABLE_ON & _CPD_OFF ;------------------------------------------------------------- ; REGISTERS AND PORTS ;------------------------------------------------------------- RT equ 0x23 org 0x00 goto main ;-------------------------- ; MAIN ;-------------------------- main movlw d'8' ;8bits to send movwf RT ;move '8' to register RT bcf STATUS,RP1 bsf STATUS,RP0 ;BANK1 movlw b'00000010' ;PORTB-bit1 : Input of the switch movwf TRISB movlw b'11000000' ;PORTC-6/7 : Serial ports movwf TRISC ;------------------------------------------------------------- ; Transmit configuration ;------------------------------------------------------------- bsf TXSTA,BRGH ;Fast Mode bcf TXSTA,SYNC bcf STATUS,RP0 ;BANK0 bsf TXSTA,SPEN bsf PIR1,TXIF=20 bsf RCSTA,SPEN ;enable asynchronous port bsf STATUS,RP0 ;BANK1 bsf TXSTA,TXEN ;enable transmission bsf TXSTA,TRMT ;set TRMT bit bcf STATUS,RP0 ;BANK0 ;------------------------------------------------------------- ; TRANSMIT ;------------------------------------------------------------- w1 btfss PORTB,1 ;If the switch is 'zero' , stay in the loop w1 goto w1=20 call zend1 ;Switch=3D'1' , go to subroutine zend1 loop1 btfsc PORTB,1 ;Switch is still '1' , stay in loop1 goto loop1 goto w1 ;switch is zero , goto w1 ;------------------------------------------------------------- ; Zend1 ;------------------------------------------------------------- zend1 movlw b'00100100' ;put the word in w movwf TXREG ;transmit the word loop2 decfsz RT,1 ;decrement 8 goto loop2 return=20 end -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads