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

Modifying kbd.c (from ccs) to use in PORT_D

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



Joined: 06 Oct 2009
Posts: 9

View user's profile Send private message

Modifying kbd.c (from ccs) to use in PORT_D
PostPosted: Sun Oct 11, 2009 4:00 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Oct 11, 2009 11:18 am     Reply with quote

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.
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