@DanielRuvalcaba Thanks for your reply.
I follow your advice and I changed my code to clearly set the bits in 1'b but I still have the same problem. Here you can see the test code that I implemented:
void Sensor::init()
{
Log::info("PINSEL4: %X", LPC_PINCON->PINSEL4);
Log::info("LPC_GPIO2->FIODIR: %X", LPC_GPIO2->FIODIR);
Log::info("PINMODE4: %X", LPC_PINCON->PINMODE4);
Log::info("PINMODE_OD2: %X", LPC_PINCON->PINMODE_OD2);
LPC_PINCON->PINSEL4 &= 0xFFFFFFC3;
LPC_GPIO2->FIODIR |= 0x00000006;
LPC_PINCON->PINMODE4 |= 0x00000028;
LPC_PINCON->PINMODE4 &= 0xFFFFFFEB;
LPC_PINCON->PINMODE_OD2 |= 0x00000006;
Log::info("PINSEL4: %X", LPC_PINCON->PINSEL4);
Log::info("LPC_GPIO2->FIODIR: %X", LPC_GPIO2->FIODIR);
Log::info("PINMODE4: %X", LPC_PINCON->PINMODE4);
Log::info("PINMODE_OD2: %X", LPC_PINCON->PINMODE_OD2);
}
void Sensor::measure(void)
{
LPC_GPIO2->FIOSET |= 0x00000006;
wait_us(50);
LPC_GPIO2->FIOCLR |= 0x00000006;
wait_us(50);
LPC_GPIO2->FIOSET |= 0x00000006;
wait_us(50);
LPC_GPIO2->FIOCLR |= 0x00000006;
wait_us(50);
}
And this is what I get in the logs:
PINSEL4: 0
LPC_GPIO2->FIODIR: 1A0
PINMODE4: 28BFC
PINMODE_OD2: 0
PINSEL4: 0
LPC_GPIO2->FIODIR: 1A6
PINMODE4: 28BE8
PINMODE_OD2: 6
Then I can see that every bit is set correctly but still I got no pulses on the pins p2.1 and p2.2. Every test was made with a 10k resistor to 3.3V for pullups, but nothing happens. But if in the method measure() I put a longer delay as wait_us(1000), I get two pulses but with an incorrect random width.
As I said before, If I set these pins as simpe outputs without opendrain, then I get two pulses with the correct width of 50us and separation of 50us.
Which could be the problem here?