1 Reply Latest reply on Jun 29, 2009 5:08 AM by content.librarian

    Modify drive mode

    falcon.chang
              When i use cube ice and 21x34 pod practice modify IO port,   
      Pod only connect P17 to voltage meter, no other external component.   
      the code make me confuse. (PS. Designer 5.0)   
      ------------------------------------------------------------------------------------------------   
      PRT0GS &= ~0x08; //disconnect from global bus   
      PRT0DM2 |= 0x08;   
      PRT0DM1 &= ~0X08; //DM[2:0]=100, Slow strong high, high-z low   
      PRT0DM0 &= ~0x08;   
      PRT0DR &= ~0x08;   
         
      PRT3GS &= ~0x02; //disconnect from global bus   
      PRT3DM2 |= 0x02;   
      PRT3DM1 &= ~0x02; //DM[2:0]=100, Slow strong high, high-z low   
      PRT3DM0 &= ~0x02;   
      PRT3DR |= 0x02;   
      -----------------------------------------------------------------------------------------------   
      P17 is modified to low normally,   
      then modify P31 ,   
      P17 become high.....   
         
      Can any one tell me why ? please.   
         
      =====================================================   
      I forget the P17 and P31 both connect to analog bus....   
      Forget my stupidity.   
        • 1. Re: Modify drive mode
          content.librarian
                  Hi,   
             
          I do not know what is complete application and in which context you are doing it. But I can explain what these lines of code are doing.   
             
          PRT0GS &= ~0x08; //disconnect from global bus   
          PRT0DM2 |= 0x08;   
          PRT0DM1 &= ~0X08; //DM[2:0]=100, Slow strong high, high-z low   
          PRT0DM0 &= ~0x08;   
          PRT0DR &= ~0x08;   
             
          It will disconnect pin P0[3] from global bus if it was connected earlier. Then it will change drive mode for P0[3] to open drain drive high. Then P0[3] is turned to High-Z output by writing a '0' to its data register.   
             
          PRT3GS &= ~0x02; //disconnect from global bus   
          PRT3DM2 |= 0x02;   
          PRT3DM1 &= ~0x02; //DM[2:0]=100, Slow strong high, high-z low   
          PRT3DM0 &= ~0x02;   
          PRT3DR |= 0x02;   
             
          It will disconnect pin P3[1] from global bus if it was connected earlier. Then it will change drive mode for P3[1] to open drain drive high. Then P3[1] is turned to High output by writing a '1' to its data register.   
             
          Best regards,   
          Sachin Gupta