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 support@ccsinfo.com

EXT2 Problem
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ilker07



Joined: 03 Jun 2022
Posts: 15

View user's profile Send private message

PostPosted: Mon Jun 06, 2022 11:54 pm     Reply with quote

PrinceNai wrote:
Quote:

int_ext interrupt work but int_ext1 and int_ext2 don't work


What exactly do you mean when you say it works or doesn't work?

Quote:

I'm trying to use EXT2 interrupt with pic, but it doesn't enter the interrupt


How do you know?

As a side note, it is not a good idea to have delays inside interrupt routines.


I tested them all.
ilker07



Joined: 03 Jun 2022
Posts: 15

View user's profile Send private message

PostPosted: Mon Jun 06, 2022 11:58 pm     Reply with quote

PCM programmer wrote:
What's the Vdd voltage of the PIC ?
What are the high and low voltage levels of the incoming signal on pin INT2 ?

If the Vdd voltage is 5.0v, the high level of the input signal must be at least
4.0v according to the PIC's datasheet. The low level must be 0.8v or below.

Describe the external circuit on pin INT2.



when I use #int_ext interrupt same code works.
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Tue Jun 07, 2022 12:10 am     Reply with quote

The point is it shouldn't.
This implies that something is happening that you are not understanding
in the hardware.
Hence we need to know _exactly_ what you are actually doing.
Supply voltage.
What decoupling is on the supply.
The nature of the buzzer.
How the input is driven.
How things are wired, etc. etc..

My own suspicion is that when the buzzer is switched on, the chip is
actually resetting because of inadequate decoupling on the supply. The
code then restarts, and because of differences in the defaults of the
chip, Int0 re-triggers, while the others do not.
ilker07



Joined: 03 Jun 2022
Posts: 15

View user's profile Send private message

PostPosted: Tue Jun 07, 2022 1:22 am     Reply with quote

Ttelmah wrote:
The point is it shouldn't.
This implies that something is happening that you are not understanding
in the hardware.
Hence we need to know _exactly_ what you are actually doing.
Supply voltage.
What decoupling is on the supply.
The nature of the buzzer.
How the input is driven.
How things are wired, etc. etc..

My own suspicion is that when the buzzer is switched on, the chip is
actually resetting because of inadequate decoupling on the supply. The
code then restarts, and because of differences in the defaults of the
chip, Int0 re-triggers, while the others do not.



Code:

#include <18F67K22.h>
#use delay(internal=8000000)

#define BZ    pin_e2

void main()
{
   output_low(BZ);
   delay_ms(5000);
 
   while(TRUE)
    {
      if(input(pin_b2)) {output_high(BZ);}
      else output_low(BZ);
    }

}

I tried this code to make sure if chip is resetting or not. No, there was no problem.
PrinceNai



Joined: 31 Oct 2016
Posts: 452
Location: Montenegro

View user's profile Send private message

PostPosted: Tue Jun 07, 2022 3:21 am     Reply with quote

As the others said, tell us something about your schematics. Are you using a push button to trigger the interrupt? How is it connected? For me the usual way is with a resistor to +5 or 3.3V and a switch, when pressed, forces the input to GND. That would mean your buzzer should beep when you release the button, for 1 hundredth of a second. How much current does the buzzer need? Maybe it is a debouncing issue. You could test that by feeding a clean maybe 1Hz signal from another pin to your interrupt input. That would also solve the problem with potential inadequate voltage levels. Change the buzzer for a diode to exclude problems with the buzzer, both with current and any electrical noise it may create. Maybe change the insides of your interrupt routine to output_toggle. That way every time you depress the button diode or buzzer will change state.
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Tue Jun 07, 2022 5:25 am     Reply with quote

Understand that what this does:
Code:

#include <18F67K22.h>
#use delay(internal=8000000)

#define BZ    pin_e2

void main()
{
   output_low(BZ);
   delay_ms(5000);
 
   while(TRUE)
    {
      if(input(pin_b2)) {output_high(BZ);}
      else output_low(BZ);
    }
}

Is _not_ what the interrupt code should do.
The interrupt code should do this:
Code:

#include <18F67K22.h>
#use delay(internal=8000000)

#define BZ    pin_e2

void main()
{
   int old_port;
   old_port=input(pin_b2);
 
   while(TRUE)
   {
      if (input(pin_b2))
      {
          if (old_port==0)
          {
              output_high(BZ);
              delay_ms(10);
              output_low(BZ);   
              old_port=1;           
          }
      }
      else
           old_port=0;
   }
}


It'll only give a single 1/100th second pulse on the buzzer pin at the
moment the pin changes.
temtronic



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

View user's profile Send private message

PostPosted: Tue Jun 07, 2022 9:42 am     Reply with quote

'buzzer' ??
What TYPE of 'buzzer' ?
A PIC can supply maybe 10-15 ma on an output pin BUT not at 5 volts (in the specs......)
There are at least 3 types of 'buzzers':
1) a piezo transducer, that needs a 'driver'(extra parts...)
2) a piezo MODULE, runs off 5 volts, low current..'should' be 'pin compatible'...
3) a MECHANICAL buzzer. Can look like a 'buzzer' but draws 100s of mA !
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Tue Jun 07, 2022 9:50 am     Reply with quote

I know,
Several of us have asked for hardware details, but these have not been
provided... Sad
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 Previous  1, 2
Page 2 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