PDA

View Full Version : INTCON (RB0/INT) and TRISB



flotulopex
- 6th September 2006, 20:29
Hello,

For my different tests, I usually use a button connected to RB0. I then check INTCON to trigger any action.

To me, RB0 is an Input in this case (button).

Why is it then possible to trigger the button's action even if TRISB.0 is set as Output?

Do the "pull-ups" have any importance in this case? I made some tests but it doesn't make any change; the button still "works".

Melanie
- 7th September 2006, 09:02
What PIC are you using?

Some PICBasic commands change the I/O state automatically for you (though I never rely on that)... post the test code you are using...

As an aside, what is the picture of before the cheeses in your Switzerland advert? Exploding PIC? I knew there had to be something Hi-tech coming out of Switzerland apart from cookoo clocks...

flotulopex
- 7th September 2006, 16:18
Hello Melanie,

I'm actually working with a 16F88.

The test code (you may recall...) is for example this one:


OSCCON = %01100000 'Internal RC set to 4MHZ
LED var PORTB.4
MAIN:
if INTCON.1 = 1 then 'If INTerrupt happens, then...
pause 300 'Debounce button
INTCON.1 = 0 'Reset INT flag
TOGGLE LED
endif
goto MAIN
end


Swiss people are pacific; there would never be any explosion even if the led won't toggle after 10 hours trying... It is a small (about 2cm wide) flower named "Edelweiss" that you can mostly see in the alps. It means literally "precious white". The petals are made of a kind of white velvet and when, in the early morning hours of the day some water drops cover the petals and the sun rises, the flower is shining like it would be covered with diamonds. It's a german name and unlike, (i.e.) our city names, there is no french, italian, romanch or english (all national languages!!!) name for it.

peterdeco1
- 7th September 2006, 19:35
I am using a 16F88 in a circuit and my header is this:

OSCCON = $60 'set int osc to 4mhz
ANSEL = 0 'SELECT ANALOG INPUTS 0 = NONE AND ALL DIGITAL
ADCON0 = 0 'AD MODULE OFF & CONSUMES NO CURRENT
CMCON = 7 'COMPARATORS OFF

The PIC behaves perfectly.

mister_e
- 7th September 2006, 20:38
Looking the internal stuff at figure 5-8... it's sounds perfectly normal. It just monitor the I/O. No matter if set to input or output.

You could also get an interrupt only by enabling/disabling the internall pull-up... depending of the external impedance

So it's normal.