please dont rip this site


reverses a pin's data direction.

Setting up a particular pin as an input or output requires writing a 1 or 0 to the corresponding bit of that port's TRIS register. However, the TRIS registers are write-only, so your program must keep copies of their contents in normal RAM to perform operations like Reverse. Here is a program fragment that shows how this works:

; ***************************************************************************
; ***  Bubble Software Parallax to PIC Source Converter. Copyright 1999.  ***
; ***                 email:  ***
; ***************************************************************************
; PULSOUT port, pin, time
; Generates an output pulse in 10-cycle (10 us at 4 MHz) units,
; based on a 16-bit (1 to 65,535) value. The pulse is the reverse
; of the pin's state when pulsout is called. For instance,	if the
; specified pin is initially 1, Pulsout will invert it to make a
; negative-going pulse.

	P = pic16c55
	#include <>   ; processor assembler definitions
	_CONFIG _xt_osc & _wdt_off & _protect_off

 org 8
TRISB_copy Res d'1'

 org  0
             MOVLW b'11110000'          ; Make a copy of TRISB. 
             MOVWF TRISB_copy
             MOVF TRISB_copy,w          ; Move copy into TRISB.
             TRIS 6h
; >>TRISB now contains 11110000b. 
;        ...                     ; Other instructions. 
             MOVLW b'10000000'          ; Reverse bit 7 of copy. 
             XORWF TRISB_copy
             MOVF TRISB_copy,w          ; Move copy into TRISB. 
             TRIS 6h
; >>TRISB now contains 01110000b.

mov TRISB_copy,#11110000b ; Make a copy of TRISB. mov !rb,TRISB_copy ; Move copy into TRISB. ; >>TRISB now contains 11110000b. ... ; Other instructions. XOR TRISB_copy,#10000000b ; Reverse bit 7 of copy. mov !rb, TRISB_copy ; Move copy into TRISB. ; >>TRISB now contains 01110000b.

Instead of moving a value directly into RB's TRIS register, the program moves it into a file register named TRISB_copy. Then it puts the value into TRIS. Later, when the equivalent of the Reverse instruction is required, the program reverses (inverts) the corresponding bit of the copy, and writes the copy to TRIS. This must be done consistently throughout a program in order to work properly. If at some point the copy no longer corresponds to the contents of TRIS, the method breaks down. That's why the programs in this book avoid TRIS manipulations whenever possible; they depend too heavily on the code in the rest of the program. The result could be bugs in the operation of these routines. However, don't let this stop you from incorporating powerful TRIS-copy techniques into your programs.

See also:

file: /Techref/microchip/seepicsrc/psbpix/reverse.htm, 3KB, , updated: 2001/5/25 14:48, local time: 2017/10/21 02:09,

 ©2017 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE! / 

<A HREF=""> microchip seepicsrc psbpix reverse</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.

Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

  PICList 2017 contributors:
o List host: MIT, Site host, Top posters @20171021 RussellMc, Van Horn, David, James Cameron, Sean Breheny, IVP, alan.b.pearce, Neil, David C Brown, Bob Blick, Denny Esterline,
* Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated!
* Contributors: Richard Seriani, Sr.

Welcome to!