完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,
我有一个STM8S003F3,在双向半双工模式下配置为从机。 在它接收字节的时间内,我可以等待RXNE标志知道字节已被完全接收。但是,我想知道发送时的同一时间。 TXE没有帮助。 让我来证明一下。当有转移时,想象这是时钟。 (TXE)-_-_-_-_-_-_-_-_(RXNE) 由于TX缓冲区被复制到移位寄存器,因此字节时钟开始时的TXE变为真。这当然仅在发送模式下发生。但这显示了传输的_beginning_。 字节时钟结束时的RXNE变为真,因为RX缓冲区被从移位寄存器复制到。这仅在接收模式下发生。 我希望能够轮询同一时刻轮询RXNE,但是在传输模式下。 我试过(似乎没问题)使用BSY标志。但是,数据表本身说: 注意:请勿使用BSY标志来处理每次数据传输或接收。最好使用TXE和RXNE标志。 如果我不能使用BSY标志,那么我可以使用什么(因为RXNE没有设置为发送模式)? #slave #bidirectional #spi 以上来自于谷歌翻译 以下为原文 Hi, I have an STM8S003F3 that is configured as a slave in a bidirectional half-duplex mode. During the time it receives bytes, I can wait on the RXNE flag to know the byte has been completely received. However, I want to know the same time for when it is transmitting. TXE doesn't help. Let me demonstrate. When there is a transfer, imagine this is the clock. (TXE)-_-_-_-_-_-_-_-_(RXNE) TXE at the beginning of the clocking of the byte becomes true because the TX buffer gets copied to the shift register. This happens of course only in transmit mode. But this shows the _beginning_ of the transmission. RXNE at the end of the clocking of the byte becomes true because the RX buffer gets copied to from the shift register. This happens only in receive mode. I want to be able to poll the same moment polling RXNE would, but in transmit mode. I have tried (and it seems to be ok) to use the BSY flag. However, the datasheet itself says: Note: Do not use the BSY flag to handle each data transmission or reception. It is better to use TXE and RXNE flags instead. If I can't use the BSY flag, what can I use then (Since RXNE doesn't get set in transmit mode)? #slave #bidirectional #spi |
|
相关推荐
1个回答
|
|
我的测试表明,有时在传输过程中,BSY标志甚至不会在两个字节传输之间发生故障(无论我在它们之间放置什么延迟),因此看起来BSY标志对于此测试确实不可靠。
我试着等待TXE,然后查看13个时钟更改,这对于慢速通信(例如125Kpbs)有效,但由此产生的`for`-`while循环组合导致每个边缘的检测延迟大约为1.2us,这对于高端来说是不可接受的。 SPI速率(例如4Mbps)。 有没有人曾经在SPI从模式下使用STM8作为双向半双工?如果不知道在传输一个字节后何时切换到接收模式是安全的,那么整个模式就不值得蹲下! 附:我尝试在TXE设置后立即切换到接收模式(希望微型会等待传输结束),但是立即切换到接收模式,这当然会破坏输出。 以上来自于谷歌翻译 以下为原文 My tests show that sometimes during transmission, the BSY flag doesn't even go down between two byte transfers (no matter what delay I put in between them), so it seems that BSY flag is indeed unreliable for this test. I tried waiting for TXE and then looking at 13 clock changes which works for slow communication (e.g. 125Kpbs), but the resulting `for`-`while` loop combination results in about 1.2us detection delay for each edge, which is unacceptable for high SPI rates (e.g. 4Mbps). Has anyone ever used STM8 as bidirectional half-duplex in SPI slave-mode? Without knowing when it's safe to switch to receive mode after the transmission of a byte, this whole mode wouldn't be worth a squat! P.S. I tried switching to receive mode right after TXE is set (hoping the micro would wait for the transmission to end), but that immediately switched to receive mode which of course corrupted the output. |
|
|
|
只有小组成员才能发言,加入小组>>
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
2725 浏览 1 评论
3237 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
1807 浏览 1 评论
3646 浏览 6 评论
6034 浏览 21 评论
1337浏览 4评论
197浏览 3评论
对H747I-DISCO写程序时将CN2的st-link复用为usart1,再次烧录时无法检测到stlink怎么解决?
350浏览 2评论
STM32G474RE芯片只是串口发个数据就发烫严重是怎么回事?
442浏览 2评论
STM32处理增量式编码器Z信号如何判断中断是正转的还是反向转的?
273浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-22 19:12 , Processed in 1.028013 second(s), Total 76, Slave 60 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号