We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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).
I haven't looked at the datasheet for your processor, but you have this line:
P1MDIN = 0xBF; //input is digital
It sets the bits for P1.0-P1.5,P1.7 but not for P1.6 which is the one you are having problems with.
What does the manual say?
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.
I would STRONGLY suggest you to use Silabs' configurator application, where you can select the appropricate functionality of the on-chip peripherals. Later, you can "shave" generated file manually to reduce code size if you need to do it (and also review the code as there might be some bugs occasionally). You can download it free-of-charge from the Silabs' site:
www.silabs.com/.../ConfigAndConfig2Install.zip