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

How to use push button function with PIC18F452 ?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
peachgirl
Guest







How to use push button function with PIC18F452 ?
PostPosted: Mon May 28, 2007 1:45 am     Reply with quote

Is there some one can tell me how to use interrupt for "push bouton",
The #INT_BUTTON is not defined in the 18F452.h, the data bus I use for the button is PORTD:
Code:

// Constants used in ENABLE/DISABLE_INTERRUPTS() are:
#define GLOBAL                    0xF2C0
#define INT_RTCC                  0xF220
#define INT_TIMER0                0xF220
#define INT_TIMER1                0x9D01
#define INT_TIMER2                0x9D02
#define INT_TIMER3                0xA002
#define INT_EXT                   0xF210
#define INT_EXT1                  0xF008
#define INT_EXT2                  0xF010
#define INT_RB                    0xF208
#define INT_PSP                   0x9D80
#define INT_AD                    0x9D40
#define INT_RDA                   0x9D20
#define INT_TBE                   0x9D10
#define INT_SSP                   0x9D08
#define INT_CCP1                  0x9D04
#define INT_CCP2                  0xA001
#define INT_BUSCOL                0xA008
#define INT_LOWVOLT               0xA004
#define INT_EEPROM                0xA010
inservi



Joined: 13 May 2007
Posts: 128

View user's profile Send private message

PostPosted: Mon May 28, 2007 2:13 am     Reply with quote

Hello,

For a button, there are tree external interrupt available on port B0, B1 and B3.
You need to use INT_EXT for B0, INT_EXT1 for B1 and INT_EXT2 for B2.

You can not use port D for this kind of interrupt.

Look at the EX_WAKUP.C for an example.

Best regards,
dro
_________________
in médio virtus
peachgirl
Guest







PostPosted: Mon May 28, 2007 2:28 am     Reply with quote

thank you very much

inservi wrote:
Hello,

For a button, there are tree external interrupt available on port B0, B1 and B3.
You need to use INT_EXT for B0, INT_EXT1 for B1 and INT_EXT2 for B2.

You can not use port D for this kind of interrupt.

Look at the EX_WAKUP.C for an example.

Best regards,
dro
peachgirl
Guest







PostPosted: Mon May 28, 2007 2:35 am     Reply with quote

maybe, i have not explicatied well my question,
in fact, I want to use a interrupt for a keyboard.
I can also use the way that you said?
thank you
inservi wrote:
Hello,

For a button, there are tree external interrupt available on port B0, B1 and B3.
You need to use INT_EXT for B0, INT_EXT1 for B1 and INT_EXT2 for B2.

You can not use port D for this kind of interrupt.

Look at the EX_WAKUP.C for an example.

Best regards,
dro
inservi



Joined: 13 May 2007
Posts: 128

View user's profile Send private message

PostPosted: Mon May 28, 2007 2:55 am     Reply with quote

Hello,

First I need to correct a typing error. The three (not 'tree') external interrupts are on port B0, B1 and B2 not 'B3'.

These interrupts can of course be used for a keyboard.
A keyboard is composed of several buttons. If you can make a matrix of 3 by x, then three interrupts will be enough.

If you are disturbed by the EX_WAKUP.C example, keep in mind that is only a sample for the external interupts use.

Sorry for my bad English.

Best regards,
dro
_________________
in médio virtus
inservi



Joined: 13 May 2007
Posts: 128

View user's profile Send private message

PostPosted: Mon May 28, 2007 3:22 am     Reply with quote

I just find a similar topic: http://www.ccsinfo.com/forum/viewtopic.php?t=30900

With a small sample code at the end.

dro
_________________
in médio virtus
peachgirl
Guest







PostPosted: Mon May 28, 2007 3:39 am     Reply with quote

thank you very very much

I find, my B0,B1,B2 have been used for other interrupts. Sad Sad


inservi wrote:
Hello,

First I need to correct a typing error. The three (not 'tree') external interrupts are on port B0, B1 and B2 not 'B3'.

These interrupts can of course be used for a keyboard.
A keyboard is composed of several buttons. If you can make a matrix of 3 by x, then three interrupts will be enough.

If you are disturbed by the EX_WAKUP.C example, keep in mind that is only a sample for the external interupts use.

Sorry for my bad English.

Best regards,
dro
inservi



Joined: 13 May 2007
Posts: 128

View user's profile Send private message

PostPosted: Mon May 28, 2007 5:55 am     Reply with quote

Hello,

You can use RB interrupt for B4-B7 pins changes. As there is only one interrupt for 4 pins, you need to compare the state of each pins with previous state for know which pin was changed and activated the interrupt. You can then make a 4 x n matrix.

I hope that you not yet using these pins.

dro
_________________
in médio virtus
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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