LPC1768 Problem: High pin suddenly goes to zero when the state of another pin changes

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC1768 Problem: High pin suddenly goes to zero when the state of another pin changes

1,055 Views
contr2889
Contributor III

Hi everyone,

    I have a problem with lpc1768. I have configured 2 pins (p0.24 and p0.25) as open drain with external pullups of 10k to 3.3V. The problem is, when I have p0.24 and p0.25 in high state and then set the value of p0.24 to low state, the other pin briefly change the state to low level and then go back to high state, as you can see in the attached image. p0.25 should not be split in two pulses.

 contr2889_0-1649193076537.png

here is my test code:

void Sensor::init()
{
    //para pines p0.24 y p0.25
    LPC_PINCON->PINSEL1 &= 0xFFF0FFFF;
    LPC_GPIO0->FIODIR |= 0x03000000;
    LPC_PINCON->PINMODE1 |= 0x000A0000;  
    LPC_PINCON->PINMODE1 &= 0xFFFAFFFF;
    LPC_PINCON->PINMODE_OD0 |= 0x03000000;
    LPC_GPIO0->FIOMASK3 &= 0xFC;
}
void Sensor::measure(void)
{
    sdaSCLSet(1,0);
    wait_us(50);
    sdaSCLSet(1,1);
    wait_us(50);
    sdaSCLSet(0,1);
    wait_us(50);
    sdaSCLSet(0,0);
}
void Sensor::sdaSCLSet(uint8_t sdaValue, uint8_t sclValue)
{
    uint8_t outputPins = LPC_GPIO0->FIOPIN3;
    sdaValue > 0 ? outputPins |= 0x01 : outputPins &= 0xFE;
    sclValue > 0 ? outputPins |= 0x02 : outputPins &= 0xFD;
    LPC_GPIO0->FIOPIN3 = outputPins;
}

and the code in main is:

sensor.init();
wait(1);
sensor.measure();
 
If p0.25 start in high level and then change p0.24 to high level  and then change p0.25 to low level then p024 stays in high level as should be, there is not the problem depicted before.
 
What could be the problem? 
 
Thanks for your help.
 

 

Labels (1)
0 Kudos
Reply
1 Reply

1,046 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

It appears that your code has issue.

Anyway, pls try to modify the code like.

Hope it can help you

BR

XiangJun Rong

 

void Sensor::measure(void)
{
    wait_us(50); //Rong wrote
    sdaSCLSet(1,0);
    wait_us(50);
    sdaSCLSet(1,1);
    wait_us(50);
    sdaSCLSet(0,1);
    wait_us(50);
    sdaSCLSet(0,0);
}
0 Kudos
Reply