Hi , not sure on what category to use for this topic, so using this one...
I have program a ESP8266 digital output (gpio2) on a clock that I generated using the micros() function. This part worked fine until ,
I have programmed an other output (gpio12) where I can adjust duty cycle and frequency. gpio 12 Frequency is controlled thrue analogWriteFreq(240).
I do get the 240 Hz expected on gpio12 but this makes my gpio2 output frequency down to 120 Hz, regardless of the micros i had originally set up.
/* program generating a clock ( main ) at adjustable frequency
esp8266 gpio 2 configured as digital output where a scope is attached
Frequency reading shows 1000Hz for a MCp of 500 , OK.
*** MainClock frequency changes when I use gpio12 with adjustable pwm freq
not sure why
*/
bool MC; //main Clock pulse
long MCp = 500;// MainClock pulse period in uS ( note total period is *2 )
unsigned long last_MCu = 0;// store last MainClock micros
unsigned long MCu = 0; // MainClcok micros
int clockPin = 2;
const int pwmPin = 12; // D6 ou GPIO 12 , PWM
int dutyCycle = 200;
// setting up an other output pin, gpio12, to get a 240 hz pwm signal
// enabling these two lines makes my 1000Hz mainclock running at 120Hz, why
analogWriteFreq(240);
analogWrite(pwmPin, dutyCycle);