>From: Clive Frederickson >To: 'pang khong lin' >CC: 'Piclist Post' >Subject: RE: [PIC]: Interrupt RB0/INT >Date: Fri, 9 Mar 2001 09:46:17 -0000 > >Hi Pang > >Some suggestions below, Hope they are of use. Happy Pic-ing > >Regards > >Clive Frederickson >R&D Technician (CECF Group) > > ---------- > From: pang khong lin [SMTP:klpang@HOTMAIL.COM] > Sent: 08 March 2001 15:34 > Subject: [PIC]: Interrupt RB0/INT > > Hi, > > I need some help with some simple assembly. The code are provided >below. My > questions are - > > 1. I connect the pin RB1 directly to a LED and the RBO/INT to the >ground. I then switch on the power. > The LED does not light up until the RB0/INT pin is switch to Vcc >(interrupt occurs ). This is correct. Now, I switch the RB0/INT back to >ground and reset the power supply. >The moment i reconnect the supply, the LED lights up eventhough no >interrupt occurs. Why is that so? > I found that if i disconnect the supply for a longer period of time,then >the operation is correct. > > Does it have something to do with discharging? >Yes. Until the supply has drop to near 0v the RAM in the PIC will >be maintained. So te Bit you set in PORTB register remains set, And >the >PIC sit's in SLEEP mode until an interrupt occurs which will only >set the >already set bit. >Fix = Tie a Pull-up resistor from the MCLR pin to supply (~4.7K to >10K) And a momentary switch from MCLR to 0v. Then press it to reset >the >pic.Your start up code will reset PORTB. Hi everyone, I am not very clear here. Isn't a Power On Reset is also a Reset? Which will then initialise the Program Counter and allow the MAIN portion to run? If the statements in MAIN is run, then isn't PORTB is being initialise and cleared before it goes to sleep and wait for the INT? Just to let you know, i switch off the supply for more than 2-3 min and the operation is still incorrect. Does it really takes that long for the RAM to lose charge? At the moment, what i did was that i reverse the logic and output a low when an INT occurs. This will remove the uncertainty. > >Also, Use a push button to trigger your interrupt, Its easier than a >wire link. Either by 1) A pull up resistor and a switch to 0v. or 2) >A >pull down resistor ~4.7K (RB0 to 0v) and a switch to a 100ohm >resistor to >supply. I will try this instead of reseting my supply. Thanks for the advice. > > 2. I configure RBO/INT as an interrupt pin and found that when i >connect > this pin to an LED, it lights up. > I use a meter to measure the output voltage of the pin and it >produce a > reading of 1.5V - 2.0V. > Why is this so? Is there a need to put some form of buffers or >diodes on the > respective input/output > lines? > > Although RB0 is setup as an input (Tri-state = High impeadence) You >have enabled the week pull up's. These will source enough current to >light-up your LED. So is it normal to put diodes on i/o pins which are bidirectional? Opps, the drop in voltage.... > > Can anyone provide some advice on interfacing the i/o pins of PIC >with other > analog/digital circuits? > > Best to read up some tutorials / intro's to the PIC. Farnel have >some in the catalogue (if you can get it, Try www.farnell.co.uk > ) or search the web. I think Nigel Goodwin has a >web site with info and links to other pic web sites. >(It's all I can recall from my little brain right now) > > Thanks for any advice. > > org 0 > goto MAIN > > org 4 ; Interrupt Service Routine > goto INTSER > > MAIN bank1 > movlw B'00000000' > movwf TRISA > movlw B'00011101' > movwf TRISB > bank0 > clrf PORTA > clrf PORTB > bank1 > bcf OPTREG,RBPU > bsf OPTREG,INTEDG > bcf INTCON,INTF > bsf INTCON,INTE > bsf INTCON,GIE > > LOOP sleep ; let IRQ wake it up and determine >functions > nop > nop > nop > goto LOOP > > ; Only RB0/INT is considered, other interrupts are disabled. > > INTSER movwf w_temp > swapf STATUS,W > movwf status_temp > bcf INTCON,INTF > bank0 > bsf PORTB,1 ;bring the phone off hook > ENDINT swapf status_temp,W > movwf STATUS > swapf w_temp,F > swapf w_temp,W > retfie > > END > >_________________________________________________________________________ > Get Your Private, Free E-mail from MSN Hotmail at >http://www.hotmail.com. > > >*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* >Dyson's Contrarotator(TM) is the first washing machine with 2 >drums rotating in opposite directions at once. This means it >gives the cleanest wash results in the fastest time and takes >the largest loads. The Contrarotator(TM) is now on sale at >selected retailers, and will be available nationwide in spring 2001. > >For more information, >please visit our website at http://www.dyson.com. >*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.