Hello,
I would like to optimize consumption during the time the cpu wait the uart receipt.
I wrote below the different way and names i found on internet documentation about :
STM32 ------------ machine ---------- pyb --------------- time
sleep ---------------- idle ------------ wfi ---------- time.sleep(time_ms)
stop --------------- sleep ---------- stop
standby --------- deepsleep ----- standby
STMicroelectronics answered me it is possible to wake up from stop mode with uart here :
https://community.st.com/s/question/0D70X0000068uFP/how-wake-up-a-stm32f7-in-standby-mode-with-a-external-uart-receipt?s1oid=00Db0000000YtG6&s1nid=0DB0X000000DYbd&emkind=chatterCommentNotification&s1uid=0050X0000088eWl&emtm=1543847336573&fromEmail=1&s1ext=0
altough i dont know if i can get the first uart receipt data.
I connected Rx of uart 3 with PB3 to get an external interruption on uart receipt, then I tried this code with different ways below :
import sensor,image,pyb,time, machine
red_led = pyb.LED(1)
red_led.off()
UARTSIZE = 8
uart=pyb.UART(3,14400)
uart.init(14400, bits=8, parity=None, stop=1, timeout_char=20) #, timeout_char=20
def readUART():
if uart.any():
uchar=uart.read(UARTSIZE)
if len(uchar) == UARTSIZE :
return uchar
return
rtc = pyb.RTC()
rtc.datetime((2014, 5, 1, 4, 13, 0, 0, 0))
#rtc.wakeup(5)
def test(arg):
#extint.disable()
pass
extint = pyb.ExtInt('P3', pyb.ExtInt.IRQ_FALLING, pyb.Pin.PULL_NONE, test)
while(True):
time.sleep(10)
#rtc.wakeup(20,test)
#extint.enable()
#machine.idle()
#extint.enable()
#pyb.stop()
#pyb.wfi()
uchar=readUART()
if uchar :
#red_led.toggle()
if uchar[3] == 0x0D :
red_led.toggle()
Unfortunately, i dont get the full uart rx if i stop the cpu.
The time.sleep(10) is the best way to have the lowest consumption.
Am i right ?
Thanks,