View previous topic :: View next topic |
Author |
Message |
huhu
Joined: 23 Apr 2013 Posts: 3
|
Interrupt stop when multimeter on pin |
Posted: Tue Apr 30, 2013 11:59 am |
|
|
Hi all!
I want to receive an irda signal, and put out to 2 output pin (16F628).
The LED pin flashing correctly when data comes , but when I measure with a multimeter(1Mohm res) on the PIN_A1, the LED stop flashing.
PIN_A1 not changed.
(I try with 10kohm pull up resistor too in PIN_A1)
(I try another pin too)
Why?
I copy a code from here: http://www.ccsinfo.com/forum/viewtopic.php?t=44113
I use 16F628 and 16f688 pic, but the same.
Code: | #include <16F628.h>
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC_IO //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#use delay(clock=4000000)
#define LED PIN_B4
#define DELAY 1000
#use FIXED_IO(A_outputs=PIN_A1)
int1 a[58]={}; //array for storing the complete stream
int flag=0,state,i;
#int_TIMER0
void timer0_interrupt(void)
{
set_timer0(65258);//value of T i-e 444 us
if(!input(PIN_A2))
{
a[state]=0;//store 0 in array
state++; //increament the postion
output_high(LED);
}
else if(input(PIN_A2))
{
a[state]=1;//store 1 in array
state++; //increament the postion
output_low(LED);
output_low(PIN_A1);
}
if(state>=58)//if stream is complete then disable the timer 0
{
state=0;
flag=1;
}
}
#int_EXT
void isr_ext(void)
{
flag=0;
set_timer0(65397);//value of 1/2T i-e 222 us
enable_interrupts(INT_TIMER0);
}
//!
//!
void main()
{
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1|RTCC_8_bit);
ext_int_edge(2,H_TO_L);//when interrupt goes high to low (falling edge)
enable_interrupts(INT_EXT);//enable int2
enable_interrupts(Global); //enable global interrupts
while(true)
{
if(flag==1)
{
disable_interrupts(INT_TIMER0);
for(i=0;i<58;i++)
{
}
flag=2;
}
}
}
|
10kohm pull up on MCLR, 100nF and 100uF between VDD, Vss. On solderless breadboard. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Apr 30, 2013 1:22 pm |
|
|
Quote: | set_timer0(65397);
set_timer0(65258);
|
Timer0 is an 8-bit timer in the 16F628. The maximum count it can hold is 255.
Quote: | ext_int_edge(2, H_TO_L); |
16F628 only has one external input pin (not 3). Therefore, the parameter
of "2" does nothing.
Quote: | but when I measure with a multimeter(1Mohm res) on the PIN_A1, the LED stop flashing |
It could be a static electricity issue. Put one hand on a good earth ground
(for example, a screw on the back of your PC), and then use the other
hand to hold the multimeter. |
|
|
huhu
Joined: 23 Apr 2013 Posts: 3
|
|
Posted: Wed May 01, 2013 7:25 am |
|
|
Thank you PCM programmer for the corrections.
It may be an electrical noise, this is the very first time that I use solderless breadboard.
|
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Wed May 01, 2013 11:35 am |
|
|
Quote: | It may be an electrical noise, this is the very first time that I use solderless breadboard. |
I hope you've remembered to fit HF decoupling caps as close as possible to the power supply pins on the PIC.
Mike |
|
|
huhu
Joined: 23 Apr 2013 Posts: 3
|
|
Posted: Sat May 04, 2013 2:59 am |
|
|
Yes, i did.
I found lot of complaints that the solderless breadboard is so noisy.
Thanks for replies. |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Sat May 04, 2013 3:09 am |
|
|
huhu wrote: | I found lot of complaints that the solderless breadboard is so noisy. |
I've used them for donkey's years.
I think they're brilliant up to low MHz.
You have to be careful with layout, shielding is difficult, but can be done.
Use very short leads, neat wiring, plenty of decoupling.
Mike |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19549
|
|
Posted: Sat May 04, 2013 3:32 am |
|
|
Ignoring the breadboard, a multimeter lead can always cause problems. This is like attaching a three foot or so aerial to a pin. Depending on what else is radiating signals nearby, with the diode structures in the PIC input, this can effectively form a radio receiver.....
Best Wishes |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Sat May 04, 2013 4:43 am |
|
|
You can mitigate the aerial effect with a resistor (100R to 10k).
Connect one end close to the pin under test, and the other to the meter lead.
Mike |
|
|
|