--- In "Fabio Vaz" <> wrote:
>
> Hi all,
>
> I downloaded the keypad.c sample from TS ftp and it works fine on
> ts7200 but it doesn't on ts7260. When I press "2" it shows "2" followed
> by a "5" for example. It's very strange. Has anyone corrected this
> problem ?
>
> Regards,
> Fabio.
>
I had same problem. Parasitic capacitance makes that you read back
wrong data.
This is original code:
unsigned int get_keys(void) {
unsigned int pos, on = 0;
for(pos = 0; pos < 4; pos++) {
*dat = ~(1 << pos);
on |= (~(*dat >> 4) & 0xf) << (4 * pos);
}
return on;
}
This modification works for me:
unsigned int get_keys(void) {
unsigned int pos, on = 0;
for(pos = 0; pos < 4; pos++) {
*dir = 0; // all pins set as inputs
*dir = (1 << pos); // exactly one pin is set as output
*dat = 0xffffffff;
*dat = ~(1 << pos); // only one pin is set to 0
on |= (~(*dat >> 4) & 0xf) << (4 * pos);
}
return on;
}
In this way, when sweeping through colons, one always have one "off"
state (provided by *dat = 0xffffffff statement) which solves the problem
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|