In my attempt to debug the I2S output of the Thing Plus - ESP32-S3, I had two questions:
- What GPIOs can I use if GPIOs 33, 34, 38, and 39 are already used for the SD card SPI?
- Does PWM work on all GPIOs I try to use for I2S?
To answer the first question, I selected the following GPIOs based on the board schematics, ensuring they are not involved in other communication: GPIOs 1, 2, 4, 5, 6, and 7.
Next, I tried to generate pulses on these GPIOs using the following simplified code:
// PWM Configuration
#define PWM_FREQUENCY 5000 // 5 kHz
#define PWM_PERIOD (1000000 / PWM_FREQUENCY) // Period in microseconds
const int pwmPins[] = {1, 2, 4, 5, 6, 7};
const int numPins = 6;
void setup() {
for (int i = 0; i < numPins; i++) {
pinMode(pwmPins[i], OUTPUT);
}
}
void generatePWM(int pin) {
digitalWrite(pin, HIGH);
delayMicroseconds(PWM_PERIOD / 2); // 50% duty cycle
digitalWrite(pin, LOW);
delayMicroseconds(PWM_PERIOD / 2);
}
void loop() {
generatePWM(1);
..........
}
After checking the pins with an oscilloscope, I found that only GPIOs 1 and 2 were producing PWM.
Here are the test results for the selected GPIOs:
GPIO number | Board connector number | Prodused PWM |
---|---|---|
1 | 5 | V |
2 | 6 | V |
4 | 8 | X |
5 | 9 | X |
6 | 10 | X |
7 | 11 | X |
What am I missing in my understanding?