你好Abhishek,
我没有对你的代码进行全面审查,但至少有一行看起来不对我。 USART1_DR寄存器只有一个字节,所以一次不能写入五个字节,就像你一样。在你的情况下,如果你试图写'HELLO'到这个寄存器,我希望你只发送最后一个字节('O',所以十六进制0x4F)。
发送五个字节的正确方法是逐字节发送它们,你需要确保在上一个字节已经发送之后开始发送下一个字节,例如像这样:
如果您想要完整的应用程序,您可以使用UART配置的最小代码,我在下面附加+数据传输代码。我检查了一下,它工作正常。引脚PC3在此用作UART_TX线。
最好的祝福
Szymon
以上来自于谷歌翻译
以下为原文
Hello Abhishek,
I didn't make a full review of your code, but at least one line looks wrong to me. USART1_DR register has only one byte, so it is not possible to write to it five bytes in one time, like you did. In your case if you try to write 'HELLO' to this register, I would expect you will send just the last byte ('O', so hexadecimal 0x4F).
Proper way to send five bytes is to send them byte by byte and you need to make sure, that you start sending next byte after previous one is already sent, so for example like this:
If you would like to evalaute complete application, you can use the minimum code for UART configuration, which I attach below + the code for data transmission. I checked it on my side and it is working fine. Pin PC3 is used here as a UART_TX line.
Best regards
Szymon
你好Abhishek,
我没有对你的代码进行全面审查,但至少有一行看起来不对我。 USART1_DR寄存器只有一个字节,所以一次不能写入五个字节,就像你一样。在你的情况下,如果你试图写'HELLO'到这个寄存器,我希望你只发送最后一个字节('O',所以十六进制0x4F)。
发送五个字节的正确方法是逐字节发送它们,你需要确保在上一个字节已经发送之后开始发送下一个字节,例如像这样:
如果您想要完整的应用程序,您可以使用UART配置的最小代码,我在下面附加+数据传输代码。我检查了一下,它工作正常。引脚PC3在此用作UART_TX线。
最好的祝福
Szymon
以上来自于谷歌翻译
以下为原文
Hello Abhishek,
I didn't make a full review of your code, but at least one line looks wrong to me. USART1_DR register has only one byte, so it is not possible to write to it five bytes in one time, like you did. In your case if you try to write 'HELLO' to this register, I would expect you will send just the last byte ('O', so hexadecimal 0x4F).
Proper way to send five bytes is to send them byte by byte and you need to make sure, that you start sending next byte after previous one is already sent, so for example like this:
If you would like to evalaute complete application, you can use the minimum code for UART configuration, which I attach below + the code for data transmission. I checked it on my side and it is working fine. Pin PC3 is used here as a UART_TX line.
Best regards
Szymon
举报