please dont rip this site


Reverse

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.  ***
; ***  http://www.bubblesoftonline.com                 email: sales@picnpoke.com  ***
; ***************************************************************************
;
; 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 <16c55.inc>   ; 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.
             
             
             end


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 13:48, local time: 2017/11/23 10:35,
TOP NEW HELP FIND: 
54.145.124.143:LOG IN

 ©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="http://techref.massmind.org/techref/microchip/seepicsrc/psbpix/reverse.htm"> 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?

 

Welcome to massmind.org!

 

Welcome to techref.massmind.org!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .