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

how external interrupt ??
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
gamal eldeen



Joined: 29 May 2012
Posts: 29
Location: Alexandria - Egypt

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Sat Oct 13, 2012 2:51 pm     Reply with quote

ok the problem is in debouncing >>>
as when am change it the response improved
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Oct 13, 2012 2:52 pm     Reply with quote

Post a schematic of your external switch circuit, or describe it in detail.
gamal eldeen



Joined: 29 May 2012
Posts: 29
Location: Alexandria - Egypt

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Sat Oct 13, 2012 3:00 pm     Reply with quote

VCC to R (220 ohm) to push button to RB0 bin
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Oct 13, 2012 3:40 pm     Reply with quote

You need a schematic like this:
Code:


           +5v
            |
            <
            > 4.7K       
            <         ___ Push button switch 
To          |        _|_|_
PIC -----------------o   o------
pin                            |             
                              --- GND
                               -   

The resistor can be 220 ohms. It will still work. But the other side
of the button (switch) must connect to ground.
gamal eldeen



Joined: 29 May 2012
Posts: 29
Location: Alexandria - Egypt

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Sat Oct 13, 2012 4:00 pm     Reply with quote

this schematic make a problem ????

Code:


                              +5v
                               |
                               <
                               > 4.7K       
                      ___      <         
To                   _|_|_     |       
PIC -----------------o   o------
pin                                     
                     
                               
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Oct 13, 2012 4:06 pm     Reply with quote

How do you put a logic "0" level on the PIC pin with that circuit ?
You can't. It only puts a "1" level or a "floating pin" unknown level
on the PIC pin. You need to change it to my schematic.

This is why we kept asking you for a circuit description in several posts.
gamal eldeen



Joined: 29 May 2012
Posts: 29
Location: Alexandria - Egypt

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Sat Oct 13, 2012 4:30 pm     Reply with quote

thanx ... i will change it
gamal eldeen



Joined: 29 May 2012
Posts: 29
Location: Alexandria - Egypt

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Sat Oct 13, 2012 4:35 pm     Reply with quote

but i have a question:
in the isr ...
i must write RBO as:
??????????????????????
Code:
void EXT_isr(void)
{
delay_ms (50); //debounce

if( input(PIN_B0))
{
OUTPUT_D(0xf0)



or this code is enough:
Code:
 void EXT_isr(void)
{
delay_ms (50); //debounce

OUTPUT_D(0xf0);
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Oct 13, 2012 5:18 pm     Reply with quote

I'm not sure what you want to do. Do you want the PIC to get an
external interrupt when you press the switch ? If so, you can setup
the PIC to get an interrupt on the falling edge with this function:
Code:

void main()
{
ext_int_edge(H_TO_L);  // Select falling edge for interrupt
.
.
.
.

}

If you use the switch schematic that I posted, the idle state (inactive state)
of the switch is a logic "1" level. When you press the switch, then Pin B0
will go to a "0" level. That's a "falling edge" (H to L). Then you will get
an interrupt when you press the button. To get another interrupt, you
must first release the button, and then press it again.

If you do that, then you can use the 2nd code that you posted.
Mike Walne



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

View user's profile Send private message

PostPosted: Sun Oct 14, 2012 1:39 am     Reply with quote

I'm still not sure what you're trying to do.

I realise you're at the stage where you're testing that you can get peripherals to function.

What do you want to happen when you press and release the button?

1) Do you want the LEDs to light when the button is down and go off when released?

OR

2) Do you want the LEDs to go from on to off, then off to on each time the button is pressed?

OR

3) Do you just want a one time operation?

OR

4) Something else?

Mike
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