tinygo icon indicating copy to clipboard operation
tinygo copied to clipboard

stm32f407 uart can't receive data

Open RockyF opened this issue 6 months ago • 1 comments
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?

RockyF avatar May 16 '25 08:05 RockyF

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!

deadprogram avatar May 24 '25 19:05 deadprogram