Skip to main content
Elik Livnat
Associate III
February 25, 2020
Question

Why low voltage on VBAT hold the read command on UART port

  • February 25, 2020
  • 9 replies
  • 3189 views

I experience a problem when the capacitor is fully discharge. When the program try to read from a UART port it stall on the read command and the application will not continue.If I put a delay before the read for the time that it takes the capacitor to charge to 1.8V then the read is successful and the application continue.

Is there is any explanation why the low voltage halt the reading from UART when VBAT voltage is below the 1.8V?

Thank you.

This topic has been closed for replies.

9 replies

TDK
Super User
February 25, 2020

What BOR setting are you using? What chip? How far below 1.8V are you running?

There is a minimum voltage requirement and if you’re below it, operation is not guaranteed.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Elik Livnat
Associate III
February 26, 2020

Hi Thank you.

The chip is STM32F765.

The capacitor can get almost to zero V if the unit stay for long time w/o power.

BOR is OB_BOR_OFF.

waclawek.jan
Super User
February 26, 2020

You mean, a supercap on the VBAT pin? Post relevant part of you schematics (power supply arrangement) or a sketch of it.

Try to change the BOR setting.

JW

Elik Livnat
Associate III
February 26, 2020

Here is the schematic. If I increase the burn out I might have to wait even more until the capacitor charged.

The part I do not understand why the uart port on read command get stuck until the capacitor is charged. The capacitor should be charged in a 1 sec and the VBAT should have the threshold level in about 20mS.

Thank you.

TDK
Super User
February 26, 2020
UART read is a blocking operation. Are you sure data is actually being sent after it has been initialized? Where in your code is it getting stuck?
"If you feel a post has answered your question, please click ""Accept as Solution""."
Elik Livnat
Associate III
February 26, 2020

I send a write command to a port and wait. If the wait is too short like here 250mS The read command and the app get stuck forever without any error.

If I increase the sleep to couple of second the read command will go through.

i8_err = write(pDeviceSetting->i8_tty2_fdThermalControl, "W 42a7 0\n", strlen("W 42a7 0\n")+2);

usleep(250000);

do

{

u8_cnt_start++;

if((i16_n = read(pDeviceSetting->i8_tty2_fdThermalControl, thermal_temp_buf , BUFFER_SIZE)) == -1)

{

printf("ERROR: %d\n", i16_n);

}else {

printf("READ NO. OF BYTES:%d\n", i16_n);

if(strlen(thermal_temp_buf) > 0)

{

if(strncmp(tbuf_rd2, thermal_temp_buf, 3) == 0 || strncmp(tbuf_ack, thermal_temp_buf, 3) == 0)

{

printf("SUCCESS BUFFER:%s\n", thermal_temp_buf);

printf("INIT FROM OK+++++++++++\n");

i16_returened = 0;

}else {

i16_returened = -1;

printf("FAIL BUFFER:%s\n", thermal_temp_buf);

}

}

}

if(u8_cnt_start > 100)

{

break;

}

} while (i16_returened == -1);

TDK
Super User
February 26, 2020
Ok... and what do write and read do?
Is the uart in loopback or is another device responding? Seems like you have a software bug rather than a vbat issue.
Maybe read() is only reading a few characters, which isnt enough to trigger your conditions. Then you throw those characters away instead of buffering them for when the rest come in.
"If you feel a post has answered your question, please click ""Accept as Solution""."
Elik Livnat
Associate III
February 26, 2020

At this stage only main thread is open and only the serial ports are already configured.

The issue not that it try to read, it's that it get stuck not even performing read command, in other word if I use debug the software get to the read line and get stuck there. I cannot proceed from there to try to write again in the loop.

I checked and there is data coming out from the TX. Is there no way to timeout the read command?

TDK
Super User
February 26, 2020
read() is not a standard UART command. I have no idea what yours is doing. The HAL UART read commands do timeout. Perhaps you can switch to those or use them as a reference.
"If you feel a post has answered your question, please click ""Accept as Solution""."
Elik Livnat
Associate III
February 26, 2020

I'm using Linux OS so that is the miscommunication.

Thank you I'll try the HAL read command.

waclawek.jan
Super User
February 28, 2020

0690X00000DXVhYQAX.png

Insert a series diode just before the VBAT pin, so that current can flow only *into* VBAT, not *out of* VBAT.

If this does not help, measure drops on VDD *and* GND during VCAP charging (replace VCAP with a short for that measurement). If there's significant drop, increase the charging resistor i.e. decrease charging current, reconsider layout, reconsider power supply arrangement.

JW

Elik Livnat
Associate III
February 28, 2020

Thank you I'll try it.