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 CCS Technical Support

HELP! flex keyboard 4x4 driver.

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



Joined: 23 Dec 2009
Posts: 6

View user's profile Send private message

HELP! flex keyboard 4x4 driver.
PostPosted: Wed Dec 23, 2009 9:41 am     Reply with quote

Hi everyone! I'm trying to use my 4x4 keyboard with the flex keyboard driver and I have some questions:

1. I put pull up resistors (external) to the row pins of the keyboard.
Do I have to modify the driver like this for it to work right?
Code:

void kbd_init()
{
set_tris_b(0xF0);
output_b(0xF0);
//port_b_pullups(true);
}


2. I think that the driver for the keyboard is made to work with an lcd. What do I have to do in order to get my output to 4 LEDs which will show the hexadecimal number of the button which is pressed?

Thanks in advance

Here is the schematic:

PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Dec 23, 2009 3:19 pm     Reply with quote

Quote:
Do I have to modify the driver like this for it to work right?

No. Just comment out all the code in the kbd_init() routine.
You have external pull-up resistors. You don't need the internal pull-ups.
Also, the compiler will set the TRIS automatically when it does the
output_high(), output_low(), and input() functions. Just don't specify
"fast io" mode. Let the compiler handle the TRIS.

Quote:

What do I have to do in order to get my output to 4 LEDs which will show
the hexadecimal number of the button which is pressed?

The kbd_getc() function returns an ASCII value from '0' to '9' and 'A' to 'F'.
So, you need to convert it to a 4-bit integer value, so it will display a
4-bit binary value from 0 to F. (I'm not going to handle the '*').

This function will do the conversion for you. Put this line above main().
Code:
#define toint(c)  ((c & 0x5F) > '9' ? c - '7' : c - '0')


Then, when you get the result from kbd_getc() in the 'k' variable,
remove the printf code and do this instead:
Code:
output_a(toint(k));
Guest








PostPosted: Fri Dec 25, 2009 3:01 pm     Reply with quote

Thanks for the tip it works line a charm!!!! Very Happy
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