On Thu, 14 Jul 2005 13:14:00 +0200, Francois wrote: >I found the following in a asm file for a 16f84a >Can someone tell met what is the function of the IO_MASK=0FFH &~(1< Using this convention allows a single 'equ' of IO_PIN to be used both as a bit number (for example: bsf, bcf, btfss, and btfsc instructions) and as a byte mask (for example: andlw, iorlw instructions). Changing that single 'equ' statement changes both the bit number and the mask byte. This is less error-prone than using two separate 'equ' statements since the two are always 'in sync'. >I have trouble understanding the port setup >first 0xFF is moved to W >then TRIS Port A&B wich will make them all inputs? Yes. >then W is moved to PortA&B - will this drive an input high? No. The input pins are controlled by the signals connected to them. Writing bits to port pins which are set as inputs will not change them. >and then again PortB7 is set - what is this function? > No idea. It will have no effect on the pin. One possibility that comes to mind is that, at some point in the program, the ports will some of their bits switched over to be outputs. With to output latches already set, the port will output a high rather than a low when its direction is changed. Regards, Bob >(The option command is obvoisly setting the TMR0 to 1:256 ratio) > >;***************************************************************** >IO_PIN EQU 007H ;SET INPUT / OUTPUT PIN >; >IO_MASK = 0FFH & ~(1 << IO_PIN) > > > > ORG 0000H > > GOTO start > > >start MOVLW 0FFH > TRIS PORTA > TRIS PORTB > MOVWF PORTA > MOVWF PORTB > MOVLW 07FH > OPTION > BSF PORTB,RB7 ;RB7 = 0x07 >;*********************************************************************** > >regards >Francois -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist