andyteleco wrote: >Hi, I'm writing some routines to read a DS2411 (serial number) chip using a >PIC and to send the data to a PC via a DIO card. The communication with the >chip is perfect and the number is read, but I can't send the data to the PC >since I want to use RB3 as a strobe signal and for that I need to set >TRISB(3)=0, which I can't achieve (TRISB stays at the same value after >writing on it). I'm using an MPLAB ICD2 with the PICStart Plus programmer. >The communication fails both on programmer and debugger mode. > >This is the part of the code that fails: > > > >MAIN: >BSF STATUS,RP0 ; Select Bank 1 of data memory >MOVLW 0x47 ; Initialize TRISB >MOVWF TRISB ; >BSF PORTB, 3 ; Strobe=1 ERROR!!!!! TRISB stays at 0xBF > > > Hi, In addition to Herbert's comments I found one bug (did not look for others) in your code: MAIN: BSF STATUS,RP0 ; Select Bank 1 of data memory MOVLW 0x47 ; Initialize TRISB MOVWF TRISB ; BSF PORTB, 3 ; Strobe=1 After you set TRISB you forgot to switch back to bank 0 before the BSF PORTB,3 command. Forgetting to put your code in the correct bank can cause all sorts of strange operations. Your code should look like: MAIN: BSF STATUS,RP0 ; Select Bank 1 of data memory MOVLW 0x47 ; Initialize TRISB MOVWF TRISB ; BCF STATUS,RP0 ; Select Bank 0 of data memory BSF PORTB, 3 ; Strobe=1 Hope this helps. Chris -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist