Why not using Grandpa's traditional way?
Code:i VAR BYTE for i=0 to 15 PORTB.0 = i.0 PORTB.1 = i.1 PORTB.2 = i.2 PORTB.3 = i.3 NEXT i
mister_e's #5 code is indeed short. Now it keeps upper ones unchanged.
Why not using Grandpa's traditional way?
Code:i VAR BYTE for i=0 to 15 PORTB.0 = i.0 PORTB.1 = i.1 PORTB.2 = i.2 PORTB.3 = i.3 NEXT i
mister_e's #5 code is indeed short. Now it keeps upper ones unchanged.
Last edited by sayzer; - 19th October 2006 at 04:23.
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
As the pin are set to input.... if you write to them, the result stay unchanged... as i posted. Not sure with the interrupt.
Why do you think that PORTB.7=1 or PORTB.7=0 no nothing if the TRIS.7 is not set to 0?
One thing is sure, you will clear the RBIF bit just by reading PORTB, so the above solution using Temp=PORTB will certainely cause some strange interrupt behaviour (at least you will miss some). All in the datasheet in INTCON register description.
Last edited by mister_e; - 19th October 2006 at 01:33.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Steve, yes I know reading the port, RBIF will get reset. But what about writing to the port if the upper nibble is input? Will the write cause Interrupt?
I can tolerate to loose a few while writing to the port. But producing Int's for this reason is not welcome.
Sayzer, nice idea the old recipe. I am just looking too shorten my code. I 'll see which method is shortest.
Thanks,
Ioannis
Last edited by Ioannis; - 19th October 2006 at 07:27.
Both “Temp = PortB” and “PortB = i” read the Port . Both allow for a chance of missing a change and therefore an interrupt. Steve is right in that preserving the state of the upper four pins does not appear necessary since it does not change the input values when the port is written – just the latched values should the pin directions be changed from inputs to outputs. Go with #5.
Paul Borgmeier
Salt Lake City, UT
USA
__________________
OK guys. I thought of preservint the interrupts. Anyway, sometimes your thoughts are silly without the ability to see further...
Thanks,
Ioannis
Bookmarks