problem using UART.write('x')
Posted: Wed Dec 27, 2017 9:36 am
Hey,
Currently i am working on STM32F407discovery board. So i am programming USART6 ( tx pin PC6 and rx pin pc7) for asynchronous communication. So at present i am able to read values with the help of UART.read() but UNABLE to use UART.write() function.
Below is my code , kindly go through it and help me
import pyb
from pyb import Pin, UART
tx = pyb.Pin('PC6', Pin.OUT_PP, Pin.PULL_UP)
rx = pyb.Pin('PC7', Pin.OUT_PP, Pin.PULL_UP)
#UART6_9600baudrate_8data_NoPArity_1stopbit
uart = UART(6,9600,8,None,1)
buf = bytearray(20)
uart.readinto(buf)
uart.write(buf)
So in the above code i have created array of size 20. When i use uart.readinto(buf) the keys pressed on terminal2 (baudrate 9600) are stored in the buffer. But whenever, i try to print it on terminal using uart.write(buf) , it give some sort of garbage value. I have checked the baud rate of both UART6 and terminal it's same.
Also simple functions like uart.write('123') are also not working. I think their is some mistake in my steps because uart.read() is working properly. Wishing for quick response.
Thankyou
Currently i am working on STM32F407discovery board. So i am programming USART6 ( tx pin PC6 and rx pin pc7) for asynchronous communication. So at present i am able to read values with the help of UART.read() but UNABLE to use UART.write() function.
Below is my code , kindly go through it and help me
import pyb
from pyb import Pin, UART
tx = pyb.Pin('PC6', Pin.OUT_PP, Pin.PULL_UP)
rx = pyb.Pin('PC7', Pin.OUT_PP, Pin.PULL_UP)
#UART6_9600baudrate_8data_NoPArity_1stopbit
uart = UART(6,9600,8,None,1)
buf = bytearray(20)
uart.readinto(buf)
uart.write(buf)
So in the above code i have created array of size 20. When i use uart.readinto(buf) the keys pressed on terminal2 (baudrate 9600) are stored in the buffer. But whenever, i try to print it on terminal using uart.write(buf) , it give some sort of garbage value. I have checked the baud rate of both UART6 and terminal it's same.
Also simple functions like uart.write('123') are also not working. I think their is some mistake in my steps because uart.read() is working properly. Wishing for quick response.
Thankyou