View previous topic :: View next topic |
Author |
Message |
peachgirl Guest
|
How to use push button function with PIC18F452 ? |
Posted: Mon May 28, 2007 1:45 am |
|
|
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
|
|
Posted: Mon May 28, 2007 2:13 am |
|
|
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
|
|
Posted: Mon May 28, 2007 2:28 am |
|
|
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
|
|
Posted: Mon May 28, 2007 2:35 am |
|
|
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
|
|
Posted: Mon May 28, 2007 2:55 am |
|
|
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
|
|
|
peachgirl Guest
|
|
Posted: Mon May 28, 2007 3:39 am |
|
|
thank you very very much
I find, my B0,B1,B2 have been used for other interrupts.
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
|
|
Posted: Mon May 28, 2007 5:55 am |
|
|
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 |
|
|
|