Searching \ for '[PIC]: Changing TRISB reg changes portb output?' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ios.htm?key=output
Search entire site for: 'Changing TRISB reg changes portb output?'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Changing TRISB reg changes portb output?'
2002\07\11@101911 by A.J. Tufgar

flavicon
face
Good day all,
            Simple question about the TRIS reg.  When I change the TRIS
reg direction for writing to and from an i2c bus I notice it changes
some of the other PORTB values that I'm not working with.  Is it
possible to stop this?

It changes pin 2 when modifying TRIS6.

Any ideas?

Thanks,
Aaron

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\07\11@103854 by Thomas C. Sefranek

face picon face
On 11 Jul 2002 at 10:18, A.J. Tufgar wrote:

Are you using a read-modify-write command?

{Quote hidden}

 |  __O    Thomas C. Sefranek  spam_OUTtcsTakeThisOuTspamcmcorp.com
 |_-\<,_   Amateur Radio Operator: WA1RHP
 (*)/ (*)  Bicycle mobile on 145.41, 448.625 MHz

ARRL Instructor, Technical Specialist, VE Contact.
hamradio.cmcorp.com/inventory/Inventory.html
http://www.harvardrepeater.org

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\07\11@105023 by Bob Barr

flavicon
face
On Thu, 11 Jul 2002 10:18:58 -0400, "A.J. Tufgar" wrote:

>Good day all,
>             Simple question about the TRIS reg.  When I change the TRIS
>reg direction for writing to and from an i2c bus I notice it changes
>some of the other PORTB values that I'm not working with.

Which is changing: the PORTB value or the TRISB value? You should
double check your bank selection to ensure that you're really writing
where you think you are.
> Is it
>possible to stop this?

Actually, it's not possible to do it (unless your bank selection is
wrong). :=)
>
>It changes pin 2 when modifying TRIS6.

Doing logic and math operations (see read-modify-write threads in
archives) on an internal register like TRISB shouldn't cause
unexpected bit changes. Doing those same operations on the PORTB
address can.


Regards, Bob

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\07\11@105510 by A.J. Tufgar

flavicon
face
Thomas, I'm simply using BCF and BSF to change the tris reg a bit at a
time.
I was thinking of reading portb and then writing it back after I
modifyized the tris reg, if that's what you mean, but isn't there a
problem where the output will still change for an instruction cycle?  My
modem may recognize this as the start of a start bit.

Aaron

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\07\11@105840 by A.J. Tufgar

flavicon
face
Thanks Bob,
It's portb that's changing, but I'm sure I'm writing to the TRIS reg.

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\07\11@122136 by Bob Barr

flavicon
face
On Thu, 11 Jul 2002 10:57:21 -0400, "A.J. Tufgar" wrote:

>Thanks Bob,
>It's portb that's changing, but I'm sure I'm writing to the TRIS reg.

Well, if a write to TRISB really changes the PORTB value, it sounds
like you've got yourself a broken PIC. Highly unusual but certainly
not an impossibility.


Regards, Bob

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\07\11@124035 by Dale Botkin

flavicon
face
Can you post the code you're executing when this happens?  I can think of
a couple of things, as others have mentioned -- not being in the correct
bank, for one -- but it's tough to speculate when we don't know what the
code looks like.

Have you run it through the simulator?

Dale
--
"Curiosity is the very basis of education and if you tell me that
curiosity killed the cat, I say only the cat died nobly."
         - Arnold Edinborough

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\07\11@131717 by A.J. Tufgar

flavicon
face
Dale it's weird when I had the code running on a 'F84 it was simulating
the error also, but when I put the code into a 'F627 the simulator no
longer showed the bug but the hardware did.  On the '84 I beleive RB2
went low.  The code is nothing special at all....

       BCF     PORTB, SCL
       BSF     STATUS, RP0
       BSF     TRISB, SDA
       BCF     STATUS, RP0
       BSF     PORTB,  SCL

I'm not doing anything weird or fancy, and I've never had a problem with
tris in any of my other programs.  Seems like everything in my happy
little pic world went wacky today (see other thread also :) ).  Although
this bug has been apparent for a few weeks.

I also tried a brand new pic and the problem was still there I don't
think I've blown a pic or the port would be dead I'd think.  Also it
would be a REALLY screwey was for a pic to go.  :)

Aaron

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\07\12@042118 by Carlos Ojea

flavicon
face
>I also tried a brand new pic and the problem was still there I don't
>think I've blown a pic or the port would be dead I'd think.  Also it
>would be a REALLY screwey was for a pic to go.  :)



Could be a problem of low power ?
I have seen strange things when voltage is too low.

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


More... (looser matching)
- Last day of these posts
- In 2002 , 2003 only
- Today
- New search...