tinygo
tinygo copied to clipboard
stm32f407 uart can't receive data
trafficstars
h1 = &machine.UART{
Buffer: machine.NewRingBuffer(),
Bus: stm32.USART3,
TxAltFuncSelector: machine.AF7_USART1_2_3,
RxAltFuncSelector: machine.AF7_USART1_2_3,
}
h1.Configure(machine.UARTConfig{
BaudRate: 115200,
TX: machine.PB10,
RX: machine.PB11,
})
buffer := make([]byte, 16)
for {
n, _ := h1.Read(buffer)
if n > 0 {
println("got", n)
} else {
h1.Write([]byte("aaa\r\n"))
}
time.Sleep(time.Millisecond * 1000)
}
Serial monitor print 'aaa' and send 'bbb' per second. but mcu can't receive any data.
Why? Is code correct?
Perhaps you might want to take a look at this sample: https://github.com/tinygo-org/tinygo/blob/release/src/examples/uart/uart.go
Hope that helps!