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

C8051F353 BUG writing P1.6

I have a problem trying to write to Port1 bit 6
P1.6

The pins are defined at a .H file

 sbit  Pin_E2P_SDA = P1^5;
 sbit  Pin_E2P_SCL = P1^6;
 sbit  Pin_E2P_WP  = P1^7;


and the function :

I initialized the registers according to the datasheet an according to this link.
http://www.keil.com/dd/vtr/3685/5729.htm

Can anyone give me any idea about what is happennig? Please.

Thank you
in advanced
David

void E2pEnableWrite( void )
{

 IDA0CN     = 0x00;  // DISABLE IDAC0
 IDA1CN     = 0x00;  // DISABLE IDAC1
 P1MDIN     = 0xBF;  //input is digital
 P1MDOUT    = 0x00;  //P0MDOUT.x=1,Push-pull. When   P0MDOUT.x=0, open drain
 P1SKIP     = 0x00;   // SALTO LAS  3 SALIDAS
 XBR0       = 0x00;
 XBR1       = 0x40;

 P1 = 0x40;
 P1 |= 0x40;

 Pin_E2P_WP = 1;    // Writes OK
 Pin_E2P_WP = 0;    // Writes OK

 Pin_E2P_SCL = 1;   // DoesnÂ't Write
 Pin_E2P_SCL = 0;   // DoesnÂ't Write

 Pin_E2P_SDA = 1;   // Writes OK
 Pin_E2P_SDA = 0;   // Writes OK

}

p.d. I am debugging the code with a SILICON LABS USB Debug adapater 1.9.0.0 ( EC300019BBE).

Parents
  • This register is for input only, anyway I reconfigured it as digital input but the code is not working either.

    ANother thing is that P1.6 is always set to 1

          IDA0CN     = 0x00;
          IDA1CN     = 0x00;
          P1MDIN     = 0xFF;          //input is digital
          P1MDOUT    = 0x00;   //P0MDOUT.x=1,Push-pull.        When P0MDOUT.x=0, open drain
          P1SKIP     = 0x40;   // SALTO LAS  3 SALIDAS
          XBR0       = 0x00;
          XBR1       = 0x40;
    
          P1 = 0x00;   // after this instruccion P1 = 0x40 ??? why??
          P1 |= 0x40; // after this instruccion P1 = 0x40
    
          Pin_E2P_WP = 1;  // after this instruccion P1 = 0xC0
          Pin_E2P_WP = 0;// after this instruccion P1 = 0x40
          Pin_E2P_SCL = 1; // after this instruccion P1 = 0x40
          Pin_E2P_SCL = 0; // after this instruccion P1 = 0x40 ¿¿ why???
    
          Pin_E2P_SDA = 1;    // after this instruccion P1 = 0x60
          Pin_E2P_SDA = 0;// after this instruccion P1 = 0x40
    
    
    
    

    .

    p.d. datasheet says about P1MDOUT:
    Bits7–0:Analog Input Configuration Bits for P1.7–P1.0 (respectively).Port pins configured as analog inputs have their weak pull-up, digital driver, and digital receiver disabled. 0: Corresponding P1.n pin is configured as an analog input.1: Corresponding P1.n pin is not configured as an analog input.

Reply
  • This register is for input only, anyway I reconfigured it as digital input but the code is not working either.

    ANother thing is that P1.6 is always set to 1

          IDA0CN     = 0x00;
          IDA1CN     = 0x00;
          P1MDIN     = 0xFF;          //input is digital
          P1MDOUT    = 0x00;   //P0MDOUT.x=1,Push-pull.        When P0MDOUT.x=0, open drain
          P1SKIP     = 0x40;   // SALTO LAS  3 SALIDAS
          XBR0       = 0x00;
          XBR1       = 0x40;
    
          P1 = 0x00;   // after this instruccion P1 = 0x40 ??? why??
          P1 |= 0x40; // after this instruccion P1 = 0x40
    
          Pin_E2P_WP = 1;  // after this instruccion P1 = 0xC0
          Pin_E2P_WP = 0;// after this instruccion P1 = 0x40
          Pin_E2P_SCL = 1; // after this instruccion P1 = 0x40
          Pin_E2P_SCL = 0; // after this instruccion P1 = 0x40 ¿¿ why???
    
          Pin_E2P_SDA = 1;    // after this instruccion P1 = 0x60
          Pin_E2P_SDA = 0;// after this instruccion P1 = 0x40
    
    
    
    

    .

    p.d. datasheet says about P1MDOUT:
    Bits7–0:Analog Input Configuration Bits for P1.7–P1.0 (respectively).Port pins configured as analog inputs have their weak pull-up, digital driver, and digital receiver disabled. 0: Corresponding P1.n pin is configured as an analog input.1: Corresponding P1.n pin is not configured as an analog input.

Children