This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

port setting

Hi,
I want to use port 2 of 167 on MCB net board for two peripherals, one for keyboard interface and other for lcd interface.
Please suggest some code on how to access the same port in parts.
regards
Rajesh

Parents
  • I would like to know if there is a way to give names to parts of the part.

    Sure. This is what the MACRO capability of the C Programming Language is useful for.

    For example:

    #define SET_LCD(x) {P2 = (P2 & 0xFF00) | ((x) & 0x00FF);}
    
    #define SET_KBD(x) {P2 = (P2 & 0x00FF) | (((x) & 0x00FF) << 8);}
    
    #define READ_LCD (P2 & 0x00FF)
    #define READ_KBD ((P2 & >> 8) & 0x00FF)

    In my code I could use SET_LCD(34) and SET_KBD(45) to write to the LCD and Keyboard ports respectively. I can also use READ_LCD and READ_KBD to read the LCD and keyboard ports.

    But, this is really simple programming stuff.
    Jon

Reply
  • I would like to know if there is a way to give names to parts of the part.

    Sure. This is what the MACRO capability of the C Programming Language is useful for.

    For example:

    #define SET_LCD(x) {P2 = (P2 & 0xFF00) | ((x) & 0x00FF);}
    
    #define SET_KBD(x) {P2 = (P2 & 0x00FF) | (((x) & 0x00FF) << 8);}
    
    #define READ_LCD (P2 & 0x00FF)
    #define READ_KBD ((P2 & >> 8) & 0x00FF)

    In my code I could use SET_LCD(34) and SET_KBD(45) to write to the LCD and Keyboard ports respectively. I can also use READ_LCD and READ_KBD to read the LCD and keyboard ports.

    But, this is really simple programming stuff.
    Jon

Children