ML-Cai / BBBIOlib

simple I/O library for Beaglebone Black , include some demo
BSD 3-Clause "New" or "Revised" License
70 stars 61 forks source link

4x4 keypad demo not working #9

Open vominh2012 opened 10 years ago

vominh2012 commented 10 years ago

I trying to wire and using 4x4 keypad demo, but I cannot recieved any signal when press button on keypad It always 0 value. I had change the demo code using using pulling low configuration.

Here is my Beaglebone black configuration:

P8_39 : SLEWCTRL 0 (Fast) ,RXACTIVE 0 (Disable) ,PULLTYPESEL 0 (Pulldown) ,PULLDEN 1 (Disable) ,MUXMODE : 0 | P8_39 P8_40 : SLEWCTRL 0 (Fast) ,RXACTIVE 0 (Disable) ,PULLTYPESEL 0 (Pulldown) ,PULLDEN 1 (Disable) ,MUXMODE : 0 | P8_40 P8_41 : SLEWCTRL 0 (Fast) ,RXACTIVE 0 (Disable) ,PULLTYPESEL 0 (Pulldown) ,PULLDEN 1 (Disable) ,MUXMODE : 0 | P8_41 P8_42 : SLEWCTRL 0 (Fast) ,RXACTIVE 0 (Disable) ,PULLTYPESEL 0 (Pulldown) ,PULLDEN 1 (Disable) ,MUXMODE : 0 | P8_42 P8_43 : SLEWCTRL 0 (Fast) ,RXACTIVE 0 (Disable) ,PULLTYPESEL 0 (Pulldown) ,PULLDEN 1 (Disable) ,MUXMODE : 0 | P8_43 P8_44 : SLEWCTRL 0 (Fast) ,RXACTIVE 0 (Disable) ,PULLTYPESEL 0 (Pulldown) ,PULLDEN 1 (Disable) ,MUXMODE : 0 | P8_44 P8_45 : SLEWCTRL 0 (Fast) ,RXACTIVE 0 (Disable) ,PULLTYPESEL 0 (Pulldown) ,PULLDEN 1 (Disable) ,MUXMODE : 0 | P8_45 P8_46 : SLEWCTRL 0 (Fast) ,RXACTIVE 0 (Disable) ,PULLTYPESEL 0 (Pulldown) ,PULLDEN 1 (Disable) ,MUXMODE : 0 | P8_46

ML-Cai commented 10 years ago

Hi, tranhuanltv

4x4 keypad demo use P8_39~P8_46 for GPIO ,in your EP_STATUS , these pins are configured to pinmux mode 0 (LCD_DATA mode) rather than mode 7 (GPIO mode).

Expansion header P8 share P8_31~ P8_46 with HDMI , in other words , you must disable HDMI to use this demo .

This blog have some information about disable HDMI .

if diable HDMI successfully , the MUXMODE field will be 7(GPIO mode):

P8_46 : SLEWCTRL 0 (Fast) ,RXACTIVE 0 (Disable) ,PULLTYPESEL 0 (Pulldown) ,PULLDEN 1 (Disable) ,MUXMODE : 7 | P8_46

by the way , if you want to keep HDMI , the circuit must be changed .

Please using EP_STATUS to find some GPIO pins (MUXMODE 7) for row/column scan set .

The GPIO ID in row scan pin set or column scan pin set must same , ex : P8_39~ P8_46 are all GPIO 2 ,

the GPIO of row set and column set could be different , ex : P8_11 ,P8_12, P8_15, P8_16(all GPIO 1) as row set . P8_13 ,P8_14, P8_17, P8_19(all GPIO 0) as column set .

base on the GPIO number you choosen, using BBBIO_GPIO_set_dir() to set pin's output status (notice the parametaer) in keypad_4x4_init(), change the GPIO ID in keypad_4x4_scan() .

vominh2012 commented 10 years ago

Thank you so much for your very detailed explanation! after disable HDMI it working now

vominh2012 commented 10 years ago

One notice is that P8_45 or P8_46 when connect with resistor 10K & P9_3(3V) will make Beaglebone Black can't start after unplug & plug again, currently I don't know why

vominh2012 commented 9 years ago

I must using another pins avoid P8_45 & P8_46 to avoid make BBB cannot boot. But when I change connect P9_3 to Ground P8_41 & P8_43 make this problem happen again. Any one know the reason? I do some research but don't have any clue

ML-Cai commented 9 years ago

Sorry for late reply .

Accroding to BBB_SRM , pin 31 to pin 46 as the SYSBOOT pins .

there are some contents in page 62 (Figure 35) and page 92 (8.1.1LCD Pins) .

in page 93. " These pins are also the SYSBOOT pins. DO NOT drive them before the SYS_RESETN signal goes high. If you do, the board may not boot because you would be changing the boot order of the processor "

and in page 63 , "If you choose to override these settings, it is strongly recommended that you gate these signals with the SYS_RESETn signal. This ensures that after coming out of reset these signals are removed from the expansion pins."

I think this problem cause by this issue .

I will take a test to verify this conjecture in these week .

ML-Cai commented 9 years ago

Hi ,tranhuanltv

I did some experiment for my last post .


For this case "P8_45 & P8_46 connect with resistor 10K & P9_3 (3V) will make BBB booting failed"

Main idea gating P8_45 & P8_46 signal with SYS_RESETn (P9_10) signal .

Test method

using 74245 to gating siganl

* 74LS245's DIS connect to ground . * 74LS245's A1 connect to P8_45 or P8_46 . \ 74LS245's B1 connect to resistor 10K & P9_3 (3V)

\ about the OE pin of 74LS245 . SYS_RESETn goes high after boot finish , therefore, using 7404 to invert signal SYS_RESETn , and connect it to 74LS245's OE'. According to these ,the signal input in P8_45 will be gated before booting finish .

Test result

booting successful.

In AM335x TRM page 4680 table 26-7 shows the SYSBOOT configuration pins of AM335x

if you ground P8_41 & P8_43 , the SYSBOOT[4:0] will be 01000 . On boot, the processor will look for the EMAC1 first, then microSD on the MMC0 port, followed by XIP and NANDI2C .

in this case , EMAC1 has a rather long timeout (4mis ~5mis), in other words , remove ethernet cable and ground P8_41 & P8_43 . Booting BBB and waiting 4~5mins(for EMAC1 booting timeout) , the system continuting to the next boot devie MMC0 (MicroSD)


Finally , i use some logic gate to gate signal P8_31 ~ P8_46 with SYS_RESETn, it slove this problem . BUT , i'm not sure this way is a good solution for this problem .

vominh2012 commented 9 years ago

When using P9_3(3V) I see the signals when pressing keys sometimes missed so I try to change wiring from P9_3 to Ground that make key press signals received better. So I decide to using P8_7 -> P8_10 avoid confict pins to resolved this problem. Thanks for your reply, it's show me a lot of useful information