|
|
View previous topic :: View next topic |
Author |
Message |
Marq
Joined: 06 Oct 2009 Posts: 9
|
Modifying kbd.c (from ccs) to use in PORT_D |
Posted: Sun Oct 11, 2009 4:00 am |
|
|
The below codes is taken directly from the ccs kbd.c, and i want to change it to apply in PORT_D(i am using PIC16F877A ). What
changes i should make to the code?
Furthermore, what are this value #byte kbd = 0xF81 and #byte kbd = 0xF83 is it the same for all PIC ?
Code: | // Un-comment the following define to use port B
// #define use_portb_kbd TRUE
// Make sure the port used has pull-up resistors (or the LCD) on
// the column pins
#if defined(__PCH__)
#if defined use_portb_kbd
#byte kbd = 0xF81 // This puts the entire structure
#else
#byte kbd = 0xF83 // This puts the entire structure
#endif
#else
#if defined use_portb_kbd
#byte kbd = 6 // on to port B (at address 6)
#else
#byte kbd = 8 // on to port D (at address 8)
#endif
#endif |
Can someone clarify about it, thanks. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Oct 11, 2009 11:18 am |
|
|
Quote: | What changes i should make to the code? |
Don't make any changes. Read the comments in the code. They say
exactly what to do. They say to "un-comment" the #define statement
to make it work on Port B. So, to make it work on Port D, just leave
the #define statement "commented out" (as it currently is).
Don't make any changes to it.
Quote: |
Furthermore, what are this value #byte kbd = 0xF81 and #byte kbd = 0xF83 is it the same for all PIC ? |
The code is setup to automatically compile for the correct PIC type.
If you use a 16F PIC, the lower portion of the code code will be used.
Notice that it uses Port addresses of 6 and 8. Those are for 16F PICs.
You need to study #if, #else, and #endif statements and their purpose.
They allow "conditional" compilation of code, so that one program can
be compiled with different sections of code, depending upon your settings.
Read a book on this, or read an online tutorial. |
|
|
|
|
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
|