Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
09/14/06 07:35
Read: times


 
#124271 - Lots of problems
Responding to: ???'s previous message

Firstly, you have no comments. How are we supposed to know what the code is to do? Please don't believe that since we are highly experienced that we can look at the code and infer exactly what it is to do without spending an inordinate amount of time to actually figure it out.

From what I understand from your code, I cannot see how you control the scanning of each row. Are you relying on the value read back from P1 as being what you expect? This is dangerous at best. You should have a ram or register variable that keeps track of the current selected row and use this variable for the loop control and to either lookup the value to write to the port to select the correct row or to select what bit(s) to set/clear.

Similarly to you isolating what column is active - how do you limit the loop to the first 4 bits? Again you need a ram or register variable to control this or use a selection (test col 1, test col2,test col 3,test col 4). From these two values (row & col) you combine these to form a button number that you can use to lookup a table for translation.

Depending on what instruction you are using, the value read from the port can be either the current port input state or the internal port register. As such, relying on values you have written to a port to be read back to control your program flow is inviting trouble. What happens if two port pins short together? This will give you values you may not expect. I usually only write to output port pins and use a variable to store state information.

Since you have an operational LCD, you can use this to output diagnostic information from your code. If you break your keypad code down to smaller sections, you can observe the output values on you LCD and from this determine where your code fails to do what you expect. A simulator is handy in these instances. In programming, probably 90% of time is testing and fixing bugs, with 10% actually spent on coding. Therefore you best get some practice in learning how to debug your code otherwise you'll just be an expensive chair warmer.

List of 27 messages in thread
TopicAuthorDate
Matrix Keyboard not working            01/01/70 00:00      
   the logic            01/01/70 00:00      
   Lots of problems            01/01/70 00:00      
      no, it's completely bad in concept            01/01/70 00:00      
      Does the LCD Work?            01/01/70 00:00      
      enphasizing            01/01/70 00:00      
   commented code            01/01/70 00:00      
      Persistance my friend            01/01/70 00:00      
         I'll try it in other way            01/01/70 00:00      
            I'll make the corrections            01/01/70 00:00      
      Note on comments            01/01/70 00:00      
         bad, very bad - yes, but not necessarily because            01/01/70 00:00      
            Subroutine Details            01/01/70 00:00      
               I don't know            01/01/70 00:00      
                I do not know what that information is good for.            01/01/70 00:00      
                  Column scan after ROW confirmation            01/01/70 00:00      
                     Maybe the problem is not here            01/01/70 00:00      
      more Informative code            01/01/70 00:00      
         Comments are better            01/01/70 00:00      
         The Algorithm            01/01/70 00:00      
            This isn\'t necessarily true ...            01/01/70 00:00      
               a correct pain in the gluteus maximus            01/01/70 00:00      
                  Why so much pain?            01/01/70 00:00      
               An exercise for the student            01/01/70 00:00      
               everyone else            01/01/70 00:00      
   Does the LCD Work?            01/01/70 00:00      
      LCD is fine            01/01/70 00:00      

Back to Subject List