Mode Ports

Hi!
In Hello example for 8051 by MCB900 in main() there is:
P2M1=0;
P1M1=0;

Is it ok??
Im reading the datasheet of de microcontroller and i dont understand it, because to configurate the port is using PxM1 and PxM2. Then why is writed these (bold text)??
Thanks

Parents
  • Well,
    - The chip is P89LCP936.
    - And only i want to see how can i switch on/off the led P2.
    In hello example: Write Hello in serial port this is the configuration:

    void main() {
      unsigned int j;
      P2M1 = 0;
      P1M1 = 0;
    
      SCON   = 0x52;                 /* initialize UART                            */
      BRGR0  = 0xF0;                 /* 9600 baud, 8 bit, no parity, 1 stop bit    */
      BRGR1  = 0x02;
    while (1) {
        for (j = 0x01; j <= 0x80; j <<= 1) { /* Blink LED 0,1,2,3,4,5,6 */
          P2 = j;                               /* Toggle port 2 pins each time we print */
          //printf ("Hello World\n");         /* Print "Hello World"                   */
              printf ("Hello \n");
          delay ();                         /* Delay about 0.2 seconds               */
        }
      }
    }
    

    Why :
    P2M1 = 0; P1M1 = 0;?????

    Thanks

Reply
  • Well,
    - The chip is P89LCP936.
    - And only i want to see how can i switch on/off the led P2.
    In hello example: Write Hello in serial port this is the configuration:

    void main() {
      unsigned int j;
      P2M1 = 0;
      P1M1 = 0;
    
      SCON   = 0x52;                 /* initialize UART                            */
      BRGR0  = 0xF0;                 /* 9600 baud, 8 bit, no parity, 1 stop bit    */
      BRGR1  = 0x02;
    while (1) {
        for (j = 0x01; j <= 0x80; j <<= 1) { /* Blink LED 0,1,2,3,4,5,6 */
          P2 = j;                               /* Toggle port 2 pins each time we print */
          //printf ("Hello World\n");         /* Print "Hello World"                   */
              printf ("Hello \n");
          delay ();                         /* Delay about 0.2 seconds               */
        }
      }
    }
    

    Why :
    P2M1 = 0; P1M1 = 0;?????

    Thanks

Children
More questions in this forum