I figured it out after doing some digging. Seems the ESP32-P4 has 4 channels of LDOs. And with the Esp32 Arduino Core I'm currently on (v3.2.0), the 3rd and 4th LDOs are not initialized by default.
Code: Select all
ESP LDO Channel State:
Index ID ref_cnt voltage_mv adjustable
0 1 1 3300 no
1 2 1 1900 no
2 -1 0 0 yes
3 -1 0 0 yes
Here's a simple sketch to output and initialize the
LDOs:
Code: Select all
#include "esp_ldo_regulator.h"
esp_ldo_channel_handle_t ldo2 = NULL;
esp_ldo_channel_handle_t ldo3 = NULL;
void setup() {
Serial.begin(115200);
delay(1000);
esp_ldo_dump(stdout);
// Create configuration for LDO index 2
esp_ldo_channel_config_t config2 = {
.chan_id = 3, // discovered by trial and error
.voltage_mv = 3300,
.flags = {
.adjustable = 1,
.owned_by_hw = 0,
.bypass = 0
}
};
// Create configuration for LDO index 3
esp_ldo_channel_config_t config3 = {
.chan_id = 4, // discovered by trial and error
.voltage_mv = 3300,
.flags = {
.adjustable = 1,
.owned_by_hw = 0,
.bypass = 0
}
};
// Try to acquire both channels
if (esp_ldo_acquire_channel(&config2, &ldo2) == ESP_OK) {
Serial.println("LDO index 2 acquired");
} else {
Serial.println("Failed to acquire LDO index 2");
}
if (esp_ldo_acquire_channel(&config3, &ldo3) == ESP_OK) {
Serial.println("LDO index 3 acquired");
} else {
Serial.println("Failed to acquire LDO index 3");
}
// Adjust voltage if you want to set it again (redundant if already set above)
if (ldo2) {
esp_ldo_channel_adjust_voltage(ldo2, 3300);
Serial.println("LDO index 2 voltage adjusted");
}
if (ldo3) {
esp_ldo_channel_adjust_voltage(ldo3, 3300);
Serial.println("LDO index 3 voltage adjusted");
}
// Optionally: dump to see results
esp_ldo_dump(stdout);
}
void loop(){}
And you should receive this:
Code: Select all
LDO index 2 acquired
LDO index 3 acquired
LDO index 2 voltage adjusted
LDO index 3 voltage adjusted
ESP LDO Channel State:
Index ID ref_cnt voltage_mv adjustable
0 1 1 3300 no
1 2 1 1900 no
2 3 1 3300 yes
3 4 1 3300 yes
Best regards,
microfoundry