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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/21/04 08:03
Read: times


 
#83564 - Another comment - symbolic names
Responding to: ???'s previous message
sbit LCD_RS = P1^0 ;
sbit LCD_R_W = P1^1;
sbit LCD_ENB = P1^2;

sbit TST_LED = P2^0;

You have nicely given these port bits descriptive, symbolic names; this is good, as it makes the code clearer, and means that the code can easily be changed for different connections by simply editing these definitions.

However, you have just used "P0" for the actual data writes; it'd be better to also give this a meaningful name - otherwise, to use a different port you have to go through the whole code searching for "P0" and replacing with whatever.
eg, see http://www.8052.com/forum/read.phtml?id=83435

List of 22 messages in thread
TopicAuthorDate
Help LCD--89C51 using KEIL            01/01/70 00:00      
   RE            01/01/70 00:00      
   Keil?            01/01/70 00:00      
      Keil App Notes            01/01/70 00:00      
   Assembler programmer learning C?            01/01/70 00:00      
   So what happened to the USB, then?            01/01/70 00:00      
   The wanted code...            01/01/70 00:00      
      code            01/01/70 00:00      
         Tips and Tricks.....Andy            01/01/70 00:00      
            volatile.            01/01/70 00:00      
               Not so volatile ?            01/01/70 00:00      
                  optimiser            01/01/70 00:00      
                     Volatile warning?            01/01/70 00:00      
                        not here            01/01/70 00:00      
                        re: volatile            01/01/70 00:00      
                           volatile            01/01/70 00:00      
      Another comment - symbolic names            01/01/70 00:00      
   c code for lcd            01/01/70 00:00      
      code            01/01/70 00:00      
         symbolic Port names            01/01/70 00:00      
   There's Gratitude for you! :-(            01/01/70 00:00      
   A better method in C            01/01/70 00:00      

Back to Subject List