Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By Rick
#34143 Well... I tried that approach, but changing function mode isn't working correctly :cry:
I tried the following code:
Code: Select allvoid loop() {
  // put your main code here, to run repeatedly:
  pinMode(2, FUNCTION_0);
  digitalWrite(2, LOW);
  delayMicroseconds(120);
  pinMode(2, FUNCTION_2);
  Serial1.begin(250000, SERIAL_8N2);
  Serial1.write(100);
}

but in the Serial Terminal it doesn't send correctly. Any ideas as to what I could do?
User avatar
By martinayotte
#34181 I'm not sure that pinMode() of ArduinoESP bring back to the FUNCTION_2 correctly if we look at the code in cores/esp8266/core_esp8266_wiring_digital.c, although it is handle the GPIO modes correctly.
So, maybe you need to use SDK function PIN_FUNC_SELECT directly by including eagle_soc.h.
Are you validating the signal with a logic probe capture ?
User avatar
By Rick
#35601 I am trying to use this code to change the function:

Code: Select all  PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2);
  GPIO_OUTPUT_SET(2, 1);
  delay(1000);
  GPIO_OUTPUT_SET(2, 0);
  delay(1000);
  GPIO_OUTPUT_SET(2, 1);
  delay(1);
  PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_U1TXD_BK);
  delay(1);
  Serial1.write(100);

But it doesn't send data on serial. Am I doing it wrong?
User avatar
By martinayotte
#35602 Did you have initialized the Serial1 before ?
As I mentioned earlier, did you validate with some logic analyser capture that you at least get the break ?
Did you try the same thing with Serial0 ? (because maybe Arduino doesn't handle Serial1 correctly, I've never tried it)