CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

External Interrupt
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
aaronik19



Joined: 25 Apr 2011
Posts: 297

View user's profile Send private message

External Interrupt
PostPosted: Mon Dec 30, 2013 4:03 pm     Reply with quote

PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Dec 30, 2013 4:05 pm     Reply with quote

Post your PIC and your oscillator frequency. That's pretty important.
aaronik19



Joined: 25 Apr 2011
Posts: 297

View user's profile Send private message

PostPosted: Mon Dec 30, 2013 4:42 pm     Reply with quote

You are right sorry i forgot! Thanks...

I am using pic18f4520 and 20mhz crystal.
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Dec 30, 2013 6:44 pm     Reply with quote

comment.

according to the link you posted...
"In case of an active HIGH interrupt, reverse the diodes and have a pull down resistor to GND instead."

In your first code, it appears you're looking for an 'active low' interrupt, the second an 'active high' but to do that the hardware must be changed. We need to know what configuration you've used.

Also switch 'bounce' can be a problem, giving multiple closures when you think there should only be one. Mechanical switches are very 'noisy' and need debouncing. Typically a capacitor across the contacts and a pullup( or down) resistor are used.

Since the circuit uses several diodes, perhaps you've got one or more in wrong way round ?

You can 'manually check proper operation with a simple DVM or 'scope.Simple observe the pins in the 'normal' mode, then close one switch and check each pin for logic level.Confirm that they follow the 'truth table' that they should.You should remove the PIC for this testing.

hth
jay


hth
jay
aaronik19



Joined: 25 Apr 2011
Posts: 297

View user's profile Send private message

PostPosted: Mon Dec 30, 2013 7:08 pm     Reply with quote

Temtronic, i submitted the two codes for comparison. I am looking for active low interrupt. As a good is it look fine?all diodes are in the right position and to be sure i also made a pull up resistor on every switch together with a pull up resistor on the INT pin RB0.
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Dec 30, 2013 7:37 pm     Reply with quote

hmmm. Have you disabled all other peripherals attached to the I/O pins you want as digital inputs? Stuff like ADC, comps, etc.?

with not pressed you should get 5 volts, pressed about 0.7 volts ??

hth
jay
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Dec 30, 2013 8:02 pm     Reply with quote

1. Post a list of all the PIC pins that have buttons and pull-up resistors
connected to them.

2. Post a list of the buttons that you press to get the #INT_EXT interrupt.

3. Post a list of connections to pins B0, B1, and B2.
aaronik19



Joined: 25 Apr 2011
Posts: 297

View user's profile Send private message

PostPosted: Tue Dec 31, 2013 6:43 am     Reply with quote

thanks for your feedback. JUst to understand better I draw the connections. Please refer to the image here:

http://postimg.org/image/6jm0v6lsn/

The input switches are on Port A and using THE RB0 hardware interrupt. Hope that I answered all the questions...
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Dec 31, 2013 8:14 am     Reply with quote

hmm..
What's in ..#include <zerocrossing simulation.h> ?

also I don't see where you've disabled any of the analog peripherals.

Good time to show us your entire test program.

something's not right....hard to tell without seeing the whole picture.

hth
jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Tue Dec 31, 2013 8:59 am     Reply with quote

I'd seriously consider doing it the other way up.
Problem is that unless connections are very good, you may well not get the RB0 signal low enough to trigger the interrupt.
The 'low' threshold for this pin is 0.8v (assuming you are using a 5v supply). With the typical silicon diode drop of perhaps 0.66v at room temperature, you don't have a lot of margin.
One of those things that 'ought to work', but in the real world, may well give problems....

Best Wishes
aaronik19



Joined: 25 Apr 2011
Posts: 297

View user's profile Send private message

PostPosted: Tue Dec 31, 2013 9:09 am     Reply with quote

this is the .h file requested

Code:
#include <18F4520.h>
#device ADC=16

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)

#use delay(crystal=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=comport)


my software 5.007, when select ADC to "NONE" no code will be generated. so I assume that all ADC hardware are being disabled.
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Dec 31, 2013 10:09 am     Reply with quote

comment: Mr. T may be onto the real problem, use a dvm and check what a 'low' really is.You could use Shottky diodes for lower forward voltage drop( .2 ish).Silicon is about .7 ish, Ge about .6 ish.

V5.007 is pretty 'new' might have a bug or two and I do NOT assume anything. I'd hardcode to disable adc, comparators,etc.

hth
jay
aaronik19



Joined: 25 Apr 2011
Posts: 297

View user's profile Send private message

PostPosted: Tue Dec 31, 2013 11:43 am     Reply with quote

as already stated, the interrupt is executed when I press one button. The problem is that all the code in the interrupt routine is being executed:

Code:
#INT_EXT
void  EXT_isr(void)
{
   if(!input(PIN_A0))
   {
      output_toggle(PIN_D2);
   }
   
   if(!input(PIN_A4))
   {
      output_toggle(PIN_D5);
   }
   
   
}
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Tue Dec 31, 2013 12:20 pm     Reply with quote

aaronik19 wrote:
as already stated, the interrupt is executed when I press one button. The problem is that all the code in the interrupt routine is being executed:

Code:
#INT_EXT
void  EXT_isr(void)
{
   if(!input(PIN_A0))
   {
      output_toggle(PIN_D2);
   }
   
   if(!input(PIN_A4))
   {
      output_toggle(PIN_D5);
   }
   
   
}


Now you're getting me confused.
Which version of your code is the one which works?
(The one in this, your latest post, or your original post?)

Mike
aaronik19



Joined: 25 Apr 2011
Posts: 297

View user's profile Send private message

PostPosted: Tue Dec 31, 2013 2:42 pm     Reply with quote

confused with what? I explained that I tried both active-high and active-low inputs just for testing. What I need is active-low, and also the diagram I sent. What I said is that the ISR Routine is being executed when I press the buttons. I think that the problem is in the code...understand?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group