Article Index

 

Page 239

from machine import UART,Pin
uart = UART(1,baudrate=9600,bits=8,parity=None,rx=23,tx=22)
SendData = bytearray("Hello World \n","utf-8")
uart.write(SendData)
RecData = uart.read()
print(RecData)

Page 242

from machine import UART,Pin, Timer
from utime import sleep_ms,sleep, time_ns
uart = UART(1,baudrate=9600,bits=8,parity=None,rx=23,tx=22,txbuf=256,rxbuf=16*1024)
test="A"*252
s = time_ns()
uart.write(test)
print((time_ns()-s)/1000000)

Page 242

from machine import UART,Pin, Timer
from utime import sleep_ms,sleep, time_ns
uart = UART(1,baudrate=9600,bits=8,parity=None, rx=23,tx=22, txbuf=16*1024,rxbuf=512)
test="A"*1000
s = time_ns()
uart.write(test)
print((time_ns()-s)/1000000)
sleep_ms(4000)
RecData = uart.read()
print(RecData)

Page 243

from machine import UART,Pin, Timer
from utime import sleep_ms,sleep, time_ns
uart = UART(1,baudrate=9600,bits=8,parity=None,rx=23,tx=22, txbuf=4*1024,rxbuf=512)
test = ""
for i in range(280):
   test=test + str(i)+","
print(test)
print(len(test))
s = time_ns()
uart.write(test)
print((time_ns()-s)/1000000)
sleep_ms(4000)
RecData = uart.read()
print(RecData)
print(len(RecData))

Page 247

from machine import UART,Pin
from utime import sleep_ms, time_ns

uart = UART(1,baudrate=9600,bits=8,parity=None, rx=23,tx=22,rts=21,cts=19, timeout=0,timeout_char=0,txbuf=2000,rxbuf=256,flow=UART.RTS|UART.CTS)

test = "A"*1000
s = time_ns()
uart.write(test)
print((time_ns()-s)/1000000)

RecData = bytes()
while len(RecData)<1000:
    sleep_ms(500)
    if uart.any():
            RecData = RecData + uart.read()
            print(RecData)
            print(len(RecData))