cancel
Showing results for 
Search instead for 
Did you mean: 

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

Elik Livnat
Associate II

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.

12 REPLIES 12
TDK
Guru

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 II

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.

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 II

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.

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 II

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);

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 II

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?

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".