Searching \ for '[PIC] PortB works....no it doesnt....yes it does..' 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=port
Search entire site for: 'PortB works....no it doesnt....yes it does..'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] PortB works....no it doesnt....yes it does..'
2007\12\19@165944 by alan smith

picon face
OK this is a little wierd.  Start off with some baseline code, where I have an input on PORTB bit 5.  The entire port is being used in fact for inputs, so TRISB is 0xFF.  Signal from the hall sensor works just fine, executes the code just fine.
 
 Now, add enhacements to the code, more features, etc.   Code executes down to the same point...and it does NOT see the PORTB,5 is changing. Hmmm...old code reloaded, looking
 at PORTB,5....what do ya know....its seeing it.  New code...nope...bit never changes in the watch window.
 
 I did a loop at the very top of the code to just loop on nothing so I could break it and look at the watch window.  
 
 Any thoughts?  In both cases TRISB is 0xFF

     
---------------------------------
Looking for last minute shopping deals?  Find them fast with Yahoo! Search.

2007\12\19@171844 by PAUL James

picon face

Alan,

Did your enhanced code by any chance use some peripheral that changes
the function of PORTB,5?
Just a thought.  You don't say what part you're using, so I can't be
sure, but it may be worth checking out.
Another thought.  Check to make sure you didn't inadvertantly change a
bit reference or port reference
Somewhere in your enhanced code.  I don't know how many times I've been
bitten by the fact that somehow
I changed a port from B to A or C for instance.  And it takes me a while
to track it down.
Again, just food for thought.



       


       
Regards,

       
Jim

{Original Message removed}

2007\12\19@171957 by Brian Kraut

flavicon
face
Do you set the correct register page before you do the TRISB?

Brian Kraut
Engineering Alternatives, Inc.
http://www.engalt.com

{Original Message removed}

2007\12\19@193451 by John Coppens

flavicon
face
On Wed, 19 Dec 2007 13:25:36 -0800 (PST)
alan smith <spam_OUTmicro_eng2TakeThisOuTspamyahoo.com> wrote:

... and another possibility. Are you relying on the pullups on port B?
If so, are they enabled in both versions?

John

2007\12\20@034111 by Robin Abbott

flavicon
face
Are you simulating or working on a real device ?

Really boring thought - but my experience on dubious code in the early PIC
days was down to inadequate decoupling close to the chip. Led to very
strange behaviour and dependent on outputs toggling etc.


Robin Abbott
Forest Electronics - Home of WIZ-C ANSI C Compiler for PIC's with RAD Front
end
.....robin.abbottKILLspamspam@spam@fored.co.uk
http://www.fored.co.uk


{Original Message removed}

2007\12\20@040038 by Jinx

face picon face
> Code executes down to the same point...and it does NOT see the
> PORTB,5 is changing

Have you added something that could be causing a read-modify-
write problem ? r-m-w _will_ mess with your head. Have a very
close look at activity timing and maybe try a shadow register (a
shadow register can prevent all manner of things that go bump in
the night)

2007\12\20@043241 by Tamas Rudnai

face picon face
....or looking PORTB in a wrong page --> reading TRISB instead of the port
:-)

Alan, if you look at PORTB in watch window, you will see the correct value
(if you have no HW or port initializing problem). But if you have this
pagesel thingy as Brian mentioned you would think everything is ok. Even in
the LST file you can't tell if that's good or bad. Put banksel PORTB in
front of every time you read it to see if that's the case.

Tamas



On Dec 19, 2007 10:13 PM, Brian Kraut <brian.krautspamKILLspamengalt.com> wrote:

> Do you set the correct register page before you do the TRISB?
>
> Brian Kraut
> Engineering Alternatives, Inc.
> http://www.engalt.com
>
> {Original Message removed}

2007\12\20@043741 by Alan B. Pearce

face picon face
>Now, add enhacements to the code, more features, etc.   Code executes
>down to the same point...and it does NOT see the PORTB,5 is changing.
>Hmmm...old code reloaded, looking at PORTB,5....what do ya know....its
>seeing it.  New code...nope...bit never changes in the watch window.

This sounds like a bank selection issue to me. Somewhere in the new code the
register bank is changed, and you don't change it back when dealing with the
Port register.

2007\12\20@065516 by Rikard Bosnjakovic

picon face
On 20/12/2007, Tamas Rudnai <.....tamas.rudnaiKILLspamspam.....gmail.com> wrote:
> ....or looking PORTB in a wrong page --> reading TRISB instead of the port
> :-)

That's what I did for PORTA two days ago. RA0 is (the only) input, so
TRIS was 0x1. When RA0 had no activity (i.e. 0V on it), the code that
checked the bit still called the subroutine. I even put my meter on
the pin, read 0V, and almost freaked out when the subroutine still was
called. Then, when I finally found out that it was the TRIS that was
read (the 1 in it), what a relief. And a nice experience!

But as for the time of writing, RA0 doesn't trig on a 1 any longer. No
matter if the pin is 0 or 1, the subroutine is not called. Worked fine
yesterday, but not anylonger. Code is untouched (except for have a
"banksel PORTA" before the btfsc), but still no go. That beat me and
have me get some nice scratch marks on my head. So clueless, and
confusing.


--
- Rikard - http://bos.hack.org/cv/

2007\12\20@080819 by Tamas Rudnai

face picon face
Rikard, do you have an interrupt handler that could change the bank
selection and forget to set it back before retfie by any chance? You said it
was working without the extra banksel, so maybe the interrupt triggers now
before you run to btfsc, but before the change it was triggered after that -
just a guess.

Tamas


On Dec 20, 2007 11:55 AM, Rikard Bosnjakovic <EraseMErikard.bosnjakovicspam_OUTspamTakeThisOuTgmail.com>
wrote:

{Quote hidden}

> -

2007\12\20@092407 by Rikard Bosnjakovic

picon face
On 20/12/2007, Tamas Rudnai <@spam@tamas.rudnaiKILLspamspamgmail.com> wrote:
> Rikard, do you have an interrupt handler that could change the bank
> selection and forget to set it back before retfie by any chance? You said it
> was working without the extra banksel, so maybe the interrupt triggers now
> before you run to btfsc, but before the change it was triggered after that -
> just a guess.

Could be, I'll have a look.

But since the status-register is restored before retfie, shouldn't an
occasional bankswitch (in the isr) be restored to the original bank as
well? Since the bank-info is in the status-register, I mean.


--
- Rikard - http://bos.hack.org/cv/

2007\12\20@094529 by Tamas Rudnai

face picon face
Could be many other things too, I'm just guessing as I could not see your
code neither the circuit and have no info about the signal you are about to
measure.

- It could be that the signal is low again by the time the isr returns, like
something has been done in isr that causes the signal to be going down or
the signal lasts only for a very short period of time
- It also could be that the WDT or other reset event occurs

If you drive DC to that pin at least you can be sure that there is no HW
problem... (or the chance is slim :-) )

Did you try your code on a simulator?

Tamas



On Dec 20, 2007 2:24 PM, Rikard Bosnjakovic <KILLspamrikard.bosnjakovicKILLspamspamgmail.com>
wrote:

{Quote hidden}

> -

2007\12\20@103456 by Brian Kraut

flavicon
face
I have had a mystery problem with one of my products reading rb 5 on a
16F627.  It uses a DIP switch to select a baud rate.  After it reads what
the dip switch setting is for the baud rate it changes the register pages,
changes the spbrg register to what it should be, and puts the page bits back
where they should go.  For some reason it always works if I reset power
after changing the baud rate, but the baud rate switch will not work
consistently without reseting power.  I put in code to ensure that it is at
the correct page before reading the switch with no help.  Fortunately on
this unit you set the baud rate and forget it, but it drove me nuts while
testing the unit because I would flip the baud back and forth.  I never have
figured out why it won't work like it should.


Brian Kraut
Engineering Alternatives, Inc.
http://www.engalt.com

{Original Message removed}

2007\12\20@115539 by Tamas Rudnai

face picon face
Sounds like a debouncing problem. How do you check the dip switch? Int on
change or polling it? If polling how often? If int, do you change the baud
rate inside the isr? What the device do when you switch the dip, is it
sleeping? Do you have a led or something to check what your firmware
believes about the dip position?

Tamas


On Dec 20, 2007 3:33 PM, Brian Kraut <spamBeGonebrian.krautspamBeGonespamengalt.com> wrote:

{Quote hidden}

> {Original Message removed}

2007\12\20@145738 by Bob Axtell
face picon face
Brian Kraut wrote:
> I have had a mystery problem with one of my products reading rb 5 on a
> 16F627.  It uses a DIP switch to select a baud rate.  After it reads what
> the dip switch setting is for the baud rate it changes the register pages,
> changes the spbrg register to what it should be, and puts the page bits back
> where they should go.  For some reason it always works if I reset power
> after changing the baud rate, but the baud rate switch will not work
> consistently without reseting power.  I put in code to ensure that it is at
> the correct page before reading the switch with no help.  Fortunately on
> this unit you set the baud rate and forget it, but it drove me nuts while
> testing the unit because I would flip the baud back and forth.  I never have
> figured out why it won't work like it should.
>
>
> Brian Kraut
> Engineering Alternatives, Inc.
> http://www.engalt.com
>  
Hmmm. Probably, you should do nothing for a few milliseconds while SPBRG
stabilizes. I'd try that
first, say wait 50mS. The SPBRG acts as a system clock, and the edges do
important things internally.
Next, I would disable TX and RX for another 10mS or so, then re-enable 'em.

That will probably fix it.

--Bob A

2007\12\20@160159 by Robin Abbott

flavicon
face
Did you try simulating it ? There are many obscure issues which are far
easier to debug when you simulate if you take the time to work out decent
stimulation inputs, you can do far more than even an ICD provided you are
not critically dependent on the fidelity of external device simulation.


Robin Abbott
Forest Electronics - Home of WIZ-C ANSI C Compiler for PIC's with RAD Front
end
TakeThisOuTrobin.abbottEraseMEspamspam_OUTfored.co.uk
http://www.fored.co.uk


{Original Message removed}

2007\12\20@160314 by Robin Abbott

flavicon
face
And of course try some other way to check if the switch settings are read OK
by (for example) dumping the read value on spare bits of another port or
chucking it out of the serial port.


Robin Abbott
Forest Electronics - Home of WIZ-C ANSI C Compiler for PIC's with RAD Front
end
RemoveMErobin.abbottspamTakeThisOuTfored.co.uk
http://www.fored.co.uk


{Original Message removed}

2007\12\28@134204 by alan smith

picon face
well...sorta egg on my face.  I found that the other routine nailed a timer....duh....so it was either sensing the signal on portB OR checking a timer for zero.  Guess what happened...
 
 Customer happy....me happy....me sending invoice to make me even happier...haha

     
---------------------------------
Be a better friend, newshound, and know-it-all with Yahoo! Mobile.  Try it now.

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