View previous topic :: View next topic |
Author |
Message |
zogbog
Joined: 02 Jun 2004 Posts: 16
|
4X3 Keypad |
Posted: Fri Jun 25, 2004 3:09 pm |
|
|
I need to connect a 4X3 keypad to a picdem2+ dev board. Hopefully ican do this without changing the ccs keypad driver does any one have a diagram of the circuitry required (if any) and to what pins i need to conect to. I have tried to figure it out from the CCS driver but i don't want to break anything. i believe that the keypad can share the same port as the LCD.
Any help is greatly appreciated as i am a beginer that has been making good progress up until now.
Thanks
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Jun 28, 2004 4:00 pm |
|
|
Quote: | I need to connect a 4X3 keypad to a picdem2+ dev board. |
The PicDem 2 Plus manual has a schematic in Appendix A.
http://ww1.microchip.com/downloads/en/DeviceDoc/51275b.pdf
It shows that pins B1-B7 are free. The CCS keypad driver can
be configured to use those pins.
To configure the CCS driver to use Port B, you need to define
a constant before you include the driver file. Do it as shown below.
Also, you must enable the pull-ups for Port B. Put the line to do
that at the start of main() as shown below.
#define use_portb_kbd TRUE // This line tells kbd.c to use Port B
#include <kbd.c>
main()
{
port_b_pullups(TRUE);
// Put other code here. (Code from EX_LCDKB.C)
}
Keep in mind that because the CCS keypad driver uses pins B6 and B7,
I don't think you'll be able to use the ICD2 to debug the program.
(Because the ICD2 uses those pins). But you can use ICD2 as
a programmer. Just program the PIC, and disconnect the ICD2
cable, and press reset (or cycle the power switch) to run the program. |
|
|
zogbog
Joined: 02 Jun 2004 Posts: 16
|
4X3 Keypad |
Posted: Wed Jun 30, 2004 3:21 am |
|
|
Thanks for the help.
I take it that when i am using the keypad on port b i can not use the LED outputs at the same time????
thanks again
zogbog |
|
|
omarsito12
Joined: 02 Oct 2009 Posts: 6
|
If I want to change to port F |
Posted: Fri Oct 02, 2009 10:47 am |
|
|
PCM programmer wrote: | Quote: | I need to connect a 4X3 keypad to a picdem2+ dev board. |
The PicDem 2 Plus manual has a schematic in Appendix A.
http://ww1.microchip.com/downloads/en/DeviceDoc/51275b.pdf
It shows that pins B1-B7 are free. The CCS keypad driver can
be configured to use those pins.
To configure the CCS driver to use Port B, you need to define
a constant before you include the driver file. Do it as shown below.
Also, you must enable the pull-ups for Port B. Put the line to do
that at the start of main() as shown below.
#define use_portb_kbd TRUE // This line tells kbd.c to use Port B
#include <kbd.c>
main()
{
port_b_pullups(TRUE);
// Put other code here. (Code from EX_LCDKB.C)
}
Keep in mind that because the CCS keypad driver uses pins B6 and B7,
I don't think you'll be able to use the ICD2 to debug the program.
(Because the ICD2 uses those pins). But you can use ICD2 as
a programmer. Just program the PIC, and disconnect the ICD2
cable, and press reset (or cycle the power switch) to run the program. |
//////////////////////////////////////////////////////////////////////////////////
Hi...very good your answer...it helps me a lot with my project....even thanks to you a could try my keypad 4x3 and simulate it in isis proteus...but I need a last thing for you...I need to change the driver to use this keypad on the F port of my micro!!!so please help what a need to do to make this real...'cuz I tried a lot changing the driver and proof it in proteus and nothing happens!!!Thanks for your answer again!!!
[email protected] |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Oct 02, 2009 1:00 pm |
|
|
To modify the CCS keypad driver, kbd.c, so it will work with Port F
(presumably on an 18F8722), do the following:
1. Make a copy of the kbd.c file, and name it kbd_portf.c, and edit the
new file as listed in steps 2, 3, and 4.
2. Edit the port address for Port D in kbd.c, so it's now the address for Port F (0xF85), as shown below:
Quote: |
#if defined use_portb_kbd
#byte kbd = 0xF81
#else
#byte kbd = 0xF85 // Register address for Port F
#endif
|
3. Change the 'set_tris_d' statement to 'set_tris_f' in the kbd_portf.c file,
as shown below:
Quote: | #if defined use_portb_kbd
#define set_tris_kbd(x) set_tris_b(x)
#else
#define set_tris_kbd(x) set_tris_f(x)
#endif |
4. Make sure that the line to enable use of port B is commented out.
It should look like this:
Quote: | // #define use_portb_kbd TRUE |
5. Edit the #include statement in your program to use the new driver:
Code: | #include <kbd_portf.c> |
|
|
|
|