B4R Question Strange behavior of serial port 2

Gerardo Tenreiro

Active Member
Licensed User
Hello again.
This time there is a problem that I expose:
I am using the second port of an ESP32, it seems to work correctly, I can send and receive data as normal.
When analyzing the times of the ESP32, I observe that this block of instructions take between 4 and 5 ms in each program cycle of the ESP32, which is not normal.

#if C
void SerialNative2(B4R::Object* unused)
{
::Serial2.begin(115200);
b4r_main::_serialnative2->wrappedStream = &::Serial2;
}
#End If

This piece of code is executed once at the start of the program.
Since I run this code, the program stops for about 4ms every time I activate port forwarding.
The electronic schematic is very simple.
Pin 17.TX
Pin 16.RX
Pin 18. Enable transmission
Interestingly every time I activate the transmit pin the ESP32 stops doing things for about 4ms
I am attaching the parser plot. It is as if it were waiting for characters to enter through the serial port.


Just by commenting on this instruction, the ESP32 times return to normal, but of course I do not receive the communications from the port.
attached image




It's like the serial port is started by software not hardware.
I clarify that the upper signals are oscillating once per cycle of the program
As always any help is welcome.
Thank you so much
 

Gerardo Tenreiro

Active Member
Licensed User

Hello again.
I provide some more information regarding the problem that I observe
I attach a very simple sample program. It would be necessary to have an oscilloscope or analyzer to verify the problem that I summarize.
GPIO17 and GPIO27 pins are used.
The GPIO27 PIN changes its value from FALSE to TRUE in each cycle of the ESP32
The GPIO17 PIN turns on every 2100us and turns off every 1100us.
I am attaching an image that shows that without the instruction being active, this works correctly.




As you can see the changes in the GPIO 27 PIN are continuous and stable, they do not stop and work regularly. The GPIO 17 PIN changes its value regularly every 2100us and 1100us approximately. All of this is normal and correct.
The instruction is commented.
Without further ado I delete the instruction comment and everything changes, the ESP is lost for approximately 4700us and I don't know what it is doing.
The serial port pins are not connected to anything.






I know it is very difficult to detect but I am sure that the problem is in the instruction
PS2.Initialize(SerialNative2, "VF_Newdata","VF_Error")

This means that during the time that the ESP32 is lost, it stops doing other program things.
This also prevents the CALLSUBPLUS statements from executing normally.
Please, does anyone have any idea where to look or what to do to solve this serious problem.
If anyone needs any further clarification, feel free to ask.
thank you so much


 

Attachments

  • ERROR TIEMPOS.zip
    1.3 KB · Views: 60
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…