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.
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:
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);
}