完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
我愿意在asm中初始化UART并且不确定是否需要使用Px_DDR将特定IO端口引脚配置为输出引脚,然后我才能使用UART_TX或
在UART寄存器中使能UART时,引脚是否自动配置输出类型? 例: 共用UART1_TX / PA5引脚。重置后,它是''输入'' - PA_DDR = $ 00 我想使用UART1 - 之前我是否需要此代码?: ld A,♯%00100000;使PA.5 - 输出 ld PA_DDR,A #STM8S-UART-ASM 以上来自于谷歌翻译 以下为原文 I'm willing to init UART in asm and not sure is it required to configure specific IO port pin as output pin with Px_DDR and only then then I can use UART_TX or the pin configures in output type automatically when UART is enabled in UART register? Example: There is shared UART1_TX/PA5 pin. After reset it is ''input'' - PA_DDR = $00 I want to use UART1 - prior that do I need this code or not?: ld A,♯%00100000 ; makes PA.5 - output ld PA_DDR,A #stm8s-uart-asm |
|
相关推荐
2个回答
|
|
|
你好karlen。
UART将其TX引脚配置为输出,但您必须设置Px_DDR,Px_CR1,Px_CR2和Px_ODR。 原因很简单:与UART输出相关的Px_CR1位使能推/拉输出。 如果你让UART默认配置它的TX输出引脚,它可能无法工作,因为它默认配置为开漏。 设置Px_CR2也很有用,因为它控制高逻辑电平和低逻辑电平之间的转换速度。 我建议你也将Px_ODR设置为TX空闲值,因为串行链路的另一端可能会检测到错误。 我通常使用以下说明尽快配置所有引脚: MOV PA_ODR,#%00100000 MOV PA_DDR,#%00100000 MOV PA_CR1,#%00100000 MOV PA_CR2,#%00100000 但是,您的值可能不同,因为GPIO端口引脚在各种设备和/或应用程序需求之间共享。 您还可以阅读STM8S系列参考手册和零件数据表,了解如何根据您的应用配置GPIO。 问候 EtaPhi 以上来自于谷歌翻译 以下为原文 Hello karlen. It's true that UART configures its TX pin as output, but you have to set Px_DDR, Px_CR1, Px_CR2 and Px_ODR too. There is a simple reason: the bit of Px_CR1, which is related to UART output, enables the push/pull ouput. If you let UART use its TX output pin as it's configured by default, it may not work because it's configured by default as open drain. It's also useful to set Px_CR2, since it controls the speed of transitions between high and low logic levels. I suggest you to set Px_ODR to the TX idle value too, because the other side of serial link may detect an error. I usually configure all pins as soon as possible by using the following instructions: MOV PA_ODR,#%00100000 MOV PA_DDR,#%00100000 MOV PA_CR1,#%00100000 MOV PA_CR2,#%00100000 However, your values may differ, because GPIO port pins are shared between various devices and/or application needs. You may also read STM8S family reference manual and your part datasheet to understand how to configure GPIOs according to your application. Regards EtaPhi |
|
|
|
|
|
直接操作寄存器就可以了的,找到寄存器的地址,使用指针进行操作
|
|
|
|
|
只有小组成员才能发言,加入小组>>
stm32mp157的异核通信的rpmsg_sdb的m4固件和a7驱动该如何编写?
1453 浏览 0 评论
stm32f103用freertos对一个采样率为1kHz的传感器,进行采样,数据出差
1502 浏览 0 评论
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
3649 浏览 1 评论
3842 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
2461 浏览 1 评论
STM32H7打开DCache后,出现了串口接收信息为空的现象,是哪里出了问题?
727浏览 5评论
用NANO STM32F103RBT6的开发板烧录不了是哪里出了问题?
661浏览 5评论
710浏览 5评论
外部中断触发类型为双边沿触发,进入中断回调后有什么办法判断该边沿是上升沿还是下降沿?
941浏览 5评论
STM32L071CBT6低温环境下无法正常工作是什么原因引起的?
745浏览 5评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-1 22:45 , Processed in 2.502202 second(s), Total 45, Slave 38 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
2376