Skip to content

Commit 2ac3a85

Browse files
dcpleungjhedberg
authored andcommitted
soc: mec1501: wait for UART FIFO clear before deep sleep
It is observed that after each test, weird characters appear on console. This problem goes away if deep sleep is disabled. The theory is that the CPU runs to deep sleep (_sys_suspend()) faster than UART can shift all the bits out. If we spin wait for UART FIFO to clear, this is no longer an issue. This is circumstantial evidence to the theory. So for now, put in a workaround to spin wait for UART FIFO to clear before going into deep sleep. Relates to #22885 Signed-off-by: Daniel Leung <[email protected]>
1 parent 67e43a2 commit 2ac3a85

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

soc/arm/microchip_mec/mec1501/device_power.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,22 @@ static u8_t uart_activate[3];
146146
static void deep_sleep_save_uarts(void)
147147
{
148148
uart_activate[0] = UART0_REGS->ACTV;
149+
if (uart_activate[0]) {
150+
while ((UART0_REGS->LSR & MCHP_UART_LSR_TEMT) == 0) {
151+
};
152+
}
149153
UART0_REGS->ACTV = 0;
150154
uart_activate[1] = UART1_REGS->ACTV;
155+
if (uart_activate[1]) {
156+
while ((UART1_REGS->LSR & MCHP_UART_LSR_TEMT) == 0) {
157+
};
158+
}
151159
UART1_REGS->ACTV = 0;
152160
uart_activate[2] = UART2_REGS->ACTV;
161+
if (uart_activate[2]) {
162+
while ((UART2_REGS->LSR & MCHP_UART_LSR_TEMT) == 0) {
163+
};
164+
}
153165
UART2_REGS->ACTV = 0;
154166
}
155167

0 commit comments

Comments
 (0)